Compartilhar via


Geoff Schwab's P/Invoke Sample - Call List

Input
// C# [DllImport("coredll.dll")]protected static extern uint RegisterHotKey[DllImport("coredll.dll")]protected static extern uint UnregisterFunc1[DllImport("coredll.dll")]protected static extern short GetAsyncKeyState 'VB<DllImport("coredll.dll")> Protected Shared Function RegisterHotKey<DllImport("coredll.dll")> Protected Shared Function UnregisterFunc1<DllImport("coredll.dll")> Protected Shared Function GetAsyncKeyState

Memory
//c#
[DllImport("coredll.dll")]
extern public static IntPtr LocalAlloc

[DllImport("coredll.dll")]
extern public static IntPtr LocalFree

[DllImport("coredll.dll")]
extern public static IntPtr LocalReAlloc

'VB
<DllImport("coredll.dll")>
Public Shared Function LocalAlloc

<DllImport("coredll.dll")>
Public Shared Function LocalFree

<DllImport("coredll.dll")>
Public Shared Function LocalReAlloc

Memory Status
//C#
public class MEMORYSTATUS

[DllImport("CoreDll.dll")]
public static extern void GlobalMemoryStatus

[DllImport("CoreDll.dll")]
public static extern int GetSystemMemoryDivision

'VB
Public Class MEMORYSTATUS

<DllImport("CoreDll.dll")>
Public Shared Sub GlobalMemoryStatus

<DllImport("CoreDll.dll")>
Public Shared Function GetSystemMemoryDivision

Performance Counters
C# [DllImport("CoreDll.dll")]public static extern int QueryPerformanceFrequency[DllImport("CoreDll.dll")]public static extern int QueryPerformanceCounter 'VB<DllImport("CoreDll.dll")> Public Shared Function QueryPerformanceFrequency <DllImport("CoreDll.dll")> Public Shared Function QueryPerformanceCounter

Power Status
C# public class SYSTEM_POWER_STATUS_EX2public class SYSTEM_POWER_STATUS_EX[DllImport("coredll")]public static extern uint GetSystemPowerStatusEx[DllImport("coredll")]public static extern uint GetSystemPowerStatusEx2 'VBPublic Class SYSTEM_POWER_STATUS_EX2Public Class SYSTEM_POWER_STATUS_EX<DllImport("coredll")>Public Shared Function GetSystemPowerStatusEx<DllImport("coredll")>Public Shared Function GetSystemPowerStatusEx2

SIP
C#
[DllImport("coredll.dll")]
public extern static void SipShowIM

[DllImport("coredll.dll")]
public extern static uint SipStatus();

public struct RECT

public class SIPINFO

[DllImport("coredll.dll")]
public extern static uint SipGetInfo

[DllImport("coredll.dll")]
public extern static uint SipSetInfo

'VB
<DllImport("coredll.dll")>
Public Shared Sub SipShowIM

<DllImport("coredll.dll")>
Public Shared Function SipStatus() As Integer

Public Structure RECT

Public Class SIPINFO

<DllImport("coredll.dll")>
Public Shared Function SipGetInfo

<DllImport("coredll.dll")>
Public Shared Function SipSetInfo

System Reset
C#
[DllImport("Coredll.dll")]
public extern static uint KernelIoControl

'VB
<DllImport("Coredll.dll")>
Public Shared Function KernelIoControl

System Time
//C#
public struct SYSTEMTIME

[DllImport("coredll.dll")]
public extern static void GetSystemTime

[DllImport("coredll.dll")]
public extern static uint SetSystemTime

'VB
Public Structure SYSTEMTIME

<DllImport("coredll.dll")>
Public Shared Sub GetSystemTime

<DllImport("coredll.dll")>
Public Shared Function SetSystemTime

Wave Out
//C#
[DllImport ("coredll.dll")]
protected static extern int waveOutGetNumDevs();

[DllImport ("coredll.dll")]
private static extern Wave.MMSYSERR waveOutOpen

[DllImport ("coredll.dll")]
protected static extern Wave.MMSYSERR waveOutGetVolume

[DllImport ("coredll.dll")]
protected static extern Wave.MMSYSERR waveOutSetVolume

[DllImport ("coredll.dll")]
private static extern Wave.MMSYSERR waveOutPrepareHeader

[DllImport ("coredll.dll")]
private static extern Wave.MMSYSERR waveOutWrite

[DllImport ("coredll.dll")]
private static extern Wave.MMSYSERR waveOutUnprepareHeader

[DllImport ("coredll.dll")]
protected static extern Wave.MMSYSERR waveOutClose

[DllImport ("coredll.dll")]
protected static extern Wave.MMSYSERR waveOutReset

[DllImport ("coredll.dll")]
protected static extern Wave.MMSYSERR waveOutPause

[DllImport ("coredll.dll")]
protected static extern Wave.MMSYSERR waveOutRestart

protected class MMTIME

[DllImport ("coredll.dll")]
protected static extern Wave.MMSYSERR waveOutGetPosition

protected class WAVEOUTCAPS

[DllImport ("coredll.dll")]
protected static extern Wave.MMSYSERR waveOutGetDevCaps

'VB
<DllImport("coredll.dll")>
Protected Shared Function waveOutGetNumDevs() As Integer

<DllImport("coredll.dll")>
Private Shared Function waveOutOpen

<DllImport("coredll.dll")>
Protected Shared Function waveOutGetVolume

<DllImport("coredll.dll")>
Protected Shared Function waveOutSetVolume

<DllImport("coredll.dll")>
Private Shared Function waveOutPrepareHeader

<DllImport("coredll.dll")>
Private Shared Function waveOutWrite

<DllImport("coredll.dll")>
Private Shared Function waveOutUnprepareHeader

<DllImport("coredll.dll")>
Protected Shared Function waveOutClose

<DllImport("coredll.dll")>
Protected Shared Function waveOutReset

<DllImport("coredll.dll")>
Protected Shared Function waveOutPause

<DllImport("coredll.dll")>
Protected Shared Function waveOutRestart

Protected Class MMTIME

<DllImport("coredll.dll")>
Protected Shared Function waveOutGetPosition

Protected Class WAVEOUTCAPS

<DllImport("coredll.dll")>
Protected Shared Function waveOutGetDevCaps

Wave In
C# [DllImport ("coredll.dll")]protected static extern int waveInGetNumDevs();[DllImport ("coredll.dll")]private static extern Wave.MMSYSERR waveInOpen[DllImport ("coredll.dll")]private static extern Wave.MMSYSERR waveInPrepareHeader[DllImport ("coredll.dll")]private static extern Wave.MMSYSERR waveInUnprepareHeader[DllImport ("coredll.dll")]protected static extern Wave.MMSYSERR waveInClose[DllImport ("coredll.dll")]protected static extern Wave.MMSYSERR waveInReset[DllImport ("coredll.dll")]protected static extern Wave.MMSYSERR waveInStart[DllImport ("coredll.dll")]protected static extern Wave.MMSYSERR waveInStop[DllImport ("coredll.dll")]private static extern Wave.MMSYSERR waveInAddBufferprotected class WAVEINCAPS[DllImport ("coredll.dll")]protected static extern Wave.MMSYSERR waveInGetDevCaps 'VB<DllImport("coredll.dll")>Protected Shared Function waveInGetNumDevs() As IntegerEnd Function<DllImport("coredll.dll")>Private Shared Function waveInOpen<DllImport("coredll.dll")>Private Shared Function waveInPrepareHeader<DllImport("coredll.dll")>Private Shared Function waveInUnprepareHeader<DllImport("coredll.dll")>Protected Shared Function waveInClose<DllImport("coredll.dll")>Protected Shared Function waveInReset<DllImport("coredll.dll")>Protected Shared Function waveInStart<DllImport("coredll.dll")>Protected Shared Function waveInStop<DllImport("coredll.dll")>Private Shared Function waveInAddBufferProtected Class WAVEINCAPS<DllImport("coredll.dll")>Protected Shared Function waveInGetDevCaps

Windows
//C#
[DllImport("coredll.dll")]
public static extern IntPtr GetCapture();

[DllImport("CoreDll")]
public static extern IntPtr FindWindow

[DllImport("CoreDll")]
public static extern bool ShowWindow

'VB
<DllImport("coredll.dll")>
Public Shared Function GetCapture() As IntPtr

<DllImport("CoreDll")>
Public Shared Function FindWindow

<DllImport("CoreDll")>
Public Shared Function ShowWindow

Registry
//C#
[DllImport("coredll.dll", SetLastError=true)]
public static extern int RegCreateKeyEx

[DllImport("coredll.dll", SetLastError=true)]
public static extern int RegDeleteKey

[DllImport("coredll.dll", SetLastError=true)]
public static extern int RegOpenKeyEx

[DllImport("coredll.dll", SetLastError=true)]
public static extern int RegQueryValueEx

[DllImport("coredll.dll", SetLastError=true)]
public static extern int RegSetValueEx

[DllImport("coredll.dll", SetLastError=true)]
public static extern int RegDeleteValue

[DllImport("coredll.dll", SetLastError=true)]
public static extern int RegCloseKey

'VB
<DllImport("coredll.dll", SetLastError:=True)> _
Public Shared Function RegCreateKeyEx

<DllImport("coredll.dll", SetLastError:=True)> _
Public Shared Function RegDeleteKey

<DllImport("coredll.dll", SetLastError:=True)> _
Public Shared Function RegOpenKeyEx

<DllImport("coredll.dll", SetLastError:=True)> _
Public Shared Function RegQueryValueEx

<DllImport("coredll.dll", SetLastError:=True)> _
Public Shared Function RegSetValueEx

<DllImport("coredll.dll", SetLastError:=True)> _
Public Shared Function RegDeleteValue

<DllImport("coredll.dll", SetLastError:=True)> _
Public Shared Function RegCloseKey

Phone
//C# [DllImport("Phone.dll")]private static extern int PhoneMakeCall[DllImport("Phone.dll")]private static extern void PhoneOpenCallLog[DllImport("Phone.dll")]private static extern void PhoneCloseCallLog[DllImport("Phone.dll")]private static extern void PhoneGetCallLogEntry[DllImport("Phone.dll")]private static extern void PhoneSeekCallLog 'VB<DllImport("Phone.dll")> _Private Shared Function PhoneMakeCall<DllImport("Phone.dll")> _Private Shared Sub PhoneOpenCallLog<DllImport("Phone.dll")> _Private Shared Sub PhoneCloseCallLog<DllImport("Phone.dll")> _Private Shared Sub PhoneGetCallLogEntry<DllImport("Phone.dll")> _Private Shared Sub PhoneSeekCallLog

Folders
//C# [DllImport("Coredll.dll")]static extern int SHGetSpecialFolderPath[DllImport("coredll.dll")]public static extern bool GetDiskFreeSpaceEx 'VB<DllImport("Coredll.dll")> _Shared Function SHGetSpecialFolderPath<DllImport("coredll.dll")> _Public Shared Function GetDiskFreeSpaceEx

Keyboard
//C# [DllImport("Coredll.dll")]static extern uint GetKeyboardStatus 'VB<DllImport("Coredll.dll")> _Shared Function GetKeyboardStatus

Comments