¡@

Home 

c# Programming Glossary: nativemethods

Win32 API function to programmatically enable/disable device

http://stackoverflow.com/questions/1438371/win32-api-function-to-programmatically-enable-disable-device

public Scopes Scope public int HwProfile internal class NativeMethods private const string setupapi setupapi.dll private NativeMethods.. private const string setupapi setupapi.dll private NativeMethods DllImport setupapi CallingConvention CallingConvention.Winapi.. base true protected override bool ReleaseHandle return NativeMethods.SetupDiDestroyDeviceInfoList this.handle public sealed class..

Physical disk size not correct (IoCtlDiskGetDriveGeometry)

http://stackoverflow.com/questions/15051660/physical-disk-size-not-correct-ioctldiskgetdrivegeometry

int BytesPerSector Native methods internal static class NativeMethods DllImport Kernel32.dll SetLastError true CharSet CharSet.Auto.. 0x70000 public static void Main SafeFileHandle diskHandle NativeMethods.CreateFile @ . PhysicalDrive0 NativeMethods.FileAccessGenericRead.. diskHandle NativeMethods.CreateFile @ . PhysicalDrive0 NativeMethods.FileAccessGenericRead NativeMethods.FileShareWrite NativeMethods.FileShareRead..

Change master audio volume from XP to Windows 8 in C#

http://stackoverflow.com/questions/15250379/change-master-audio-volume-from-xp-to-windows-8-in-c-sharp

volume.html The final code should be like static class NativeMethods DllImport winmm.dll EntryPoint waveOutSetVolume public static.. 0xffff uint vAll v v 16 Set the volume int retVal NativeMethods.WaveOutSetVolume IntPtr.Zero vAll catch Exception private..

How to know a process is 32-bit or 64-bit programmatically

http://stackoverflow.com/questions/1953377/how-to-know-a-process-is-32-bit-or-64-bit-programmatically

return false access is denied to the process return NativeMethods.IsWow64Process processHandle out retVal retVal return false.. return false not on 64 bit Windows internal static class NativeMethods DllImport kernel32.dll SetLastError true CallingConvention..

Accessing Password Protected Network Drives in Windows in C#?

http://stackoverflow.com/questions/2563724/accessing-password-protected-network-drives-in-windows-in-c

to the operating system. summary internal static class NativeMethods summary The type of logon operation to perform. summary internal.. bool CloseHandle IntPtr handle followed by IntPtr token if NativeMethods.LogonUser this.userName this.domain this.password NativeMethods.LogonType.NewCredentials.. this.userName this.domain this.password NativeMethods.LogonType.NewCredentials NativeMethods.LogonProvider.Default..

x86/x64 CPUID in C#

http://stackoverflow.com/questions/3216535/x86-x64-cpuid-in-c-sharp

byte buffer new byte 12 if IntPtr.Size 4 IntPtr p NativeMethods.VirtualAlloc IntPtr.Zero new UIntPtr uint x86_CPUID0_INSNS.Length.. byte newBuffer buffer 0 del newBuffer finally NativeMethods.VirtualFree p 0 FreeTypes.Release else if IntPtr.Size 8 .. p 0 FreeTypes.Release else if IntPtr.Size 8 IntPtr p NativeMethods.VirtualAlloc IntPtr.Zero new UIntPtr uint x64_CPUID0_INSNS.Length..

Loading x86 or x64 assembly

http://stackoverflow.com/questions/3787428/loading-x86-or-x64-assembly

from http sqlite.phxsoftware.com private static class NativeMethods DllImport kernel32.dll CallingConvention CallingConvention.Cdecl..

Use native HBitmap in C# while preserving alpha channel/transparency

http://stackoverflow.com/questions/4627376/use-native-hbitmap-in-c-sharp-while-preserving-alpha-channel-transparency

the BITMAP structure and get info from our nativeHBitmap NativeMethods.BITMAP bitmapStruct new NativeMethods.BITMAP NativeMethods.GetObjectBitmap.. our nativeHBitmap NativeMethods.BITMAP bitmapStruct new NativeMethods.BITMAP NativeMethods.GetObjectBitmap nativeHBitmap Marshal.SizeOf.. NativeMethods.BITMAP bitmapStruct new NativeMethods.BITMAP NativeMethods.GetObjectBitmap nativeHBitmap Marshal.SizeOf bitmapStruct ref..

Starting and stopping IIS Express programmatically

http://stackoverflow.com/questions/4772092/starting-and-stopping-iis-express-programmatically

can help somebody else. class IISExpress internal class NativeMethods Methods DllImport user32.dll SetLastError true internal static.. void SendStopMessageToProcess int PID try for IntPtr ptr NativeMethods.GetTopWindow IntPtr.Zero ptr IntPtr.Zero ptr NativeMethods.GetWindow.. NativeMethods.GetTopWindow IntPtr.Zero ptr IntPtr.Zero ptr NativeMethods.GetWindow ptr 2 uint num NativeMethods.GetWindowThreadProcessId..

How do I make a WPF window movable by dragging the extended window frame?

http://stackoverflow.com/questions/5493149/how-do-i-make-a-wpf-window-movable-by-dragging-the-extended-window-frame

lParam .ToInt32 HTCLIENT return true return false In NativeMethods DllImport user32.dll private static extern IntPtr DefWindowProc..

How can I block keyboard and mouse input in C#?

http://stackoverflow.com/questions/586547/how-can-i-block-keyboard-and-mouse-input-in-c

PInvoke signature for that method. public partial class NativeMethods Return Type BOOL int fBlockIt BOOL int System.Runtime.InteropServices.DllImportAttribute.. fBlockIt public static void BlockInput TimeSpan span try NativeMethods.BlockInput true Thread.Sleep span finally NativeMethods.BlockInput.. NativeMethods.BlockInput true Thread.Sleep span finally NativeMethods.BlockInput false EDIT Added some code to demonstrate how to..

How to distinguish between multiple input devices in C#

http://stackoverflow.com/questions/587840/how-to-distinguish-between-multiple-input-devices-in-c-sharp

However I have the following questions I get an error NativeMethods is inaccessible due to its protection level. It seems as though..

“MoveFile” function in C# (Delete file after reboot) C#

http://stackoverflow.com/questions/6077869/movefile-function-in-c-sharp-delete-file-after-reboot-c-sharp

16 FailIfNotTrackable 32 internal static class NativeMethods DllImport kernel32.dll SetLastError true CharSet CharSet.Unicode.. MoveFileFlags dwFlags And some example code if NativeMethods.MoveFileEx a.txt null MoveFileFlags.DelayUntilReboot Console.Error.WriteLine..

Pinvoke SetFocus to a particular control

http://stackoverflow.com/questions/9503027/pinvoke-setfocus-to-a-particular-control

for windows API and native calls similar to MS.Win32.UnsafeNativeMethods and it's a static class see that class or http pinvoke.net also.. or http pinvoke.net also Accessing Microsoft.Win32.UnsafeNativeMethods should be named Safe Unsafe NativeMethods http msdn.microsoft.com.. should be named Safe Unsafe NativeMethods http msdn.microsoft.com en us library ms182161.aspx and also..