Imports System.Text
Module MyModule
REM ********************************************************
REM * DLL 内 関数宣言
REM ********************************************************
Declare Function GetSystemDirectory Lib "kernel32" Alias _
"GetSystemDirectoryA" (ByVal lpBuffer As StringBuilder, ByVal nSize As Integer) As Integer
REM ********************************************************
REM * 実行
REM ********************************************************
Sub Main()
Dim strPath As new StringBuilder( 512 )
Call GetSystemDirectory( strPath, strPath.Capacity )
Call System.Console.WriteLine( strPath )
End Sub
End Module
推奨
拡張子:
Imports System.Text
Imports System.Runtime.InteropServices
Module MyModule
REM ********************************************************
REM * DLL 内 関数インターフェイス定義
REM ********************************************************
<DllImport("Kernel32.dll", CharSet:=CharSet.Auto)> _
Public Function GetSystemDirectory( _
ByVal lpBuffer As StringBuilder, _
ByVal nSize As Integer) As Integer
End Function
REM ********************************************************
REM * 実行
REM ********************************************************
Sub Main()
Dim strPath As new StringBuilder( 512 )
Call GetSystemDirectory( strPath, strPath.Capacity )
Call System.Console.WriteLine( strPath )
End Sub
End Module
Imports System.Text
Module MyModule
REM ********************************************************
REM * DLL 内 関数宣言
REM ********************************************************
Declare Function GetComputerName Lib "kernel32" Alias _
"GetComputerNameA" (ByVal lpBuffer As StringBuilder, ByRef nSize As Integer) As Integer
REM ********************************************************
REM * 実行
REM ********************************************************
Sub Main()
Dim strName As new StringBuilder( 512 )
Dim nSize As Integer = 512
Call GetComputerName( strName, nSize )
Call System.Console.WriteLine( strName )
End Sub
End Module
using System.Text;
using System.Runtime.InteropServices;
public class App
{
[ DllImport( "Kernel32.dll", CharSet=CharSet.Auto )]
public static extern int GetSystemDirectory(
StringBuilder sysDirBuffer,
int size
);
public static void Main() {
StringBuilder sysDirBuffer = new StringBuilder( 512 );
GetSystemDirectory( sysDirBuffer, sysDirBuffer.Capacity );
System.Console.WriteLine( sysDirBuffer );
}
}
using System.Text;
using System.Runtime.InteropServices;
public class App
{
[ DllImport( "Kernel32.dll", CharSet=CharSet.Auto )]
public static extern int GetComputerName(
StringBuilder strBuffer,
ref int nSize
);
public static void Main() {
StringBuilder strBuffer = new StringBuilder( 512 );
int nSize = 512;
GetComputerName( strBuffer, ref nSize );
System.Console.WriteLine( strBuffer );
}
}