ソース掲示板




すべてから検索

キーワード   条件 表示 現行ログ 過去ログ トピックス 名前 本文
.NET Framework WIN32 API 呼び出し
日時: 2008/05/12 13:15
名前: lightbox



アンマネージ DLL 関数の処理

上記ページ以下がその全てなんですが、非常にめんどくさいです。
でもま、誰かがサンプル作れば良い事なので・・・

↓VBビルド
拡張子:
vbc ソース名.bas
↓C#ビルド
拡張子:
csc ソース名.cs
※参考 ↓Framework による Jscript ソースコード
拡張子:
import System;
import System.Text;

var strDir = Environment.SystemDirectory;
System.Console.WriteLine( strDir );
↓Jscript ビルド
拡張子:
jsc ソース名.js
VB.NET 構造体をDLLに渡す
メンテナンス

VB.NET 文字列と整数 (値渡し) ( No.1 )
日時: 2008/05/12 13:18
名前: lightbox


日時: 2008/05/12 13:18
名前: lightbox
旧形式(非推奨)
拡張子:
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
このアーティクルの参照用URLをクリップボードにコピー メンテナンス
VB.NET 文字列と整数 (参照渡し) ( No.2 )
日時: 2007/07/07 20:37
名前: lightbox
拡張子:
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
このアーティクルの参照用URLをクリップボードにコピー メンテナンス
C# 文字列と整数(値渡し) ( No.3 )
日時: 2007/07/07 20:38
名前: lightbox
拡張子:
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 );
	}

}
このアーティクルの参照用URLをクリップボードにコピー メンテナンス
C# 文字列と整数 (参照渡し) ( No.4 )
日時: 2007/07/07 20:45
名前: lightbox
拡張子:
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 );
	}

}
このアーティクルの参照用URLをクリップボードにコピー メンテナンス