
TheSaib
|
::|The S@ib|::
CA ne change pas :)
using System.Runtime.InteropServices;
[DllImport ("winmm.dll")] public static extern int PlaySound(String lpszName, int hModule, int dwFlags); [DllImport ("winmm.dll")] public static extern int mciSendString(String s1, StringBuilder s2, int l1, int l2); [DllImport ("winmm.dll")] public static extern int mciGetErrorString(int l1, StringBuilder s1, int l2); [DllImport ("winmm.dll")] public static extern uint mciGetDeviceID (string lpstrName); [DllImport ("winmm.dll")] public static extern int mciSendCommand (uint wDeviceID, uint uMessage,uint dwParam1, ref object dwParam2); [DllImport ("winmm.dll")] public static extern int waveOutGetVolume (uint uDeviceID,int lpdwVolume ); [DllImport ("winmm.dll")] public static extern int waveOutSetVolume (uint uDeviceID,uint lpdwVolume ); [DllImport ("winmm.dll")]
-------------------------------------------------------------------------------------------------------------------------------------------- ********** C# ********************** sbyte -128 to 127 Signed 8-bit integer byte 0 to 255 Unsigned 8-bit integer char U+0000 to U+ffff Unicode 16-bit character short -32,768 to 32,767 Signed 16-bit integer ushort 0 to 65,535 Unsigned 16-bit integer int -2,147,483,648 to 2,147,483,647 Signed 32-bit integer uint 0 to 4,294,967,295 Unsigned 32-bit integer long -9,223,372,036,854,775,808 to 9,223,372,036,854,775,807 Signed 64-bit integer ulong 0 to 18,446,744,073,709,551,615 Unsigned 64-bit integer
********** C++ *************** BOOL A Boolean value. BSTR A 32-bit character pointer. BYTE An 8-bit integer that is not signed. COLORREF A 32-bit value used as a color value. DWORD A 32-bit unsigned integer or the address of a segment and its associated offset. LONG A 32-bit signed integer. LPARAM A 32-bit value passed as a parameter to a window procedure or callback function. LPCSTR A 32-bit pointer to a constant character string. LPSTR A 32-bit pointer to a character string. LPCTSTR A 32-bit pointer to a constant character string that is portable for Unicode and DBCS. LPTSTR A 32-bit pointer to a character string that is portable for Unicode and DBCS. LPVOID A 32-bit pointer to an unspecified type. LRESULT A 32-bit value returned from a window procedure or callback function. UINT A 16-bit unsigned integer on Windows versions 3.0 and 3.1; a 32-bit unsigned integer on Win32. WNDPROC A 32-bit pointer to a window procedure. WORD A 16-bit unsigned integer. WPARAM A value passed as a parameter to a window procedure or callback function: 16 bits on Windows versions 3.0 and 3.1; 32 bits on Win32.
C++ C# VARIANT n/a DECIMAL DECIMAL BYTE/bool byte VARIANT_BOOL bool signed short int __int16 short,char signed char, __int8 long, (long int, signed long int) int __int64 long float float double double
Converting C Declarations to Visual Basic The procedures in DLLs are most commonly documented using C language syntax. To call these procedures from Visual Basic, you need to translate them into valid Declare statements and call them with the correct arguments. As part of this translation, you must convert the C data types into Visual Basic data types and specify whether each argument should be called by value (ByVal) or implicitly, by reference (ByRef). The following table lists common C language data types and their Visual Basic equivalents for 32-bit versions of Windows.
C language Visual Basic declare as Call with ATOM ByVal variable As Integer An expression that evaluates to an Integer BOOL ByVal variable As Long An expression that evaluates to a Long BYTE ByVal variable As Byte An expression that evaluates to a Byte CHAR ByVal variable As Byte An expression that evaluates to a Byte COLORREF ByVal variable As Long An expression that evaluates to a Long DWORD ByVal variable As Long An expression that evaluates to a Long HWND, HDC, HMENU, etc. (Windows handles)ByVal variable As Long An expression that evaluates to a Long INT, UINT ByVal variable As Long An expression that evaluates to a Long LONG ByVal variable As Long An expression that evaluates to a Long LPARAM ByVal variable As Long An expression that evaluates to a Long LPDWORD variable As Long An expression that evaluates to a Long LPINT, LPUINT variable As Long An expression that evaluates to a Long LPRECT variable As type Any variable of that user-defined type LPSTR, LPCSTR ByVal variable As String An expression that evaluates to a String LPVOID variable As Any Any variable (use ByVal when passing a string) LPWORD variable As Integer An expression that evaluates to an Integer LRESULT ByVal variable As Long An expression that evaluates to a Long NULL As Any or ByVal variable As Long ByVal Nothing or ByVal 0& or vbNullString SHORT ByVal variable As Integer An expression that evaluates to an Integer VOID Sub procedure Not applicable WORD ByVal variable As Integer An expression that evaluates to an Integer WPARAM ByVal variable As Long An expression that evaluates to a Long
---------------------------------------------------------------------- -------------------------------
> J'aimerais utiliser des fonctions de l'APIen C#. Il faut pour cela redefinir les fonctions et les structures de l'API en C#. Malheureusement, je ne sais pas toujours quel types utiliser en C#... Par exemple, comment traduire un DWORD ou un un LPVOID en C# ? Visual Studio 6.0 offrait une visionneuse d'API pour convertir les fonctions de l'API en VB mais il n'existe rien de tel en C#... Quelqu'un pourrait t'il me faire un tableau de conversion des types de l'API en C# ? > > Merci d'avance.... > > Merlin Tintin > > ------------- > Pour fixer les idees, j'ai mis deux exemples: > > - Importation d'un fonction de l'API: > [ DllImport( "winmm.dll", CharSet=CharSet.Ansi )] > private static extern int mixerClose(int hmx); > > - Importation d'un structure: > > La structure de l'API: > > typedef struct tagMIXERLINECONTROLSA { > DWORD cbStruct; /* size in bytes of MIXERLINECONTROLS */ > DWORD dwLineID; /* line id (from MIXERLINE.dwLineID) */ > union { > DWORD dwControlID; /* MIXER_GETLINECONTROLSF_ONEBYID */ > DWORD dwControlType; /* MIXER_GETLINECONTROLSF_ONEBYTYPE */ > }; > DWORD cControls; /* count of controls pmxctrl points to */ > DWORD cbmxctrl; /* size in bytes of _one_ MIXERCONTROL */ > LPMIXERCONTROLA pamxctrl; /* pointer to first MIXERCONTROL array */ > } MIXERLINECONTROLSA, *PMIXERLINECONTROLSA, *LPMIXERLINECONTROLSA; > > devient en C#: > > public struct MIXERLINECONTROLS > { > public int cbStruct; > public int dwLineID; > public int dwControl; > public int cControls; > public int cbmxctrl; > public MIXERCONTROL pamxctrl; > } > > > si vous pouviez me donner la liste des conversion, ca m'arrangerait vraiment (par ex: DWORD -> ???, UINT-> ???, ...)
|