常用Win32Api调用............

原创 2004年07月15日 16:53:00

大笑微笑生气吐舌头吐舌头吐舌头吐舌头吐舌头吐舌头吐舌头吐舌头吐舌头吐舌头吐舌头生气微笑大笑


偷笑我爱北京天安门偷笑


偷笑天安门上太阳升偷笑


偷笑伟大领袖毛主席偷笑


偷笑指引我们向前进偷笑

偷笑大笑大笑大笑大笑大笑大笑大笑大笑大笑大笑大笑大笑大笑大笑大笑大笑偷笑

<p>win32api 在使用起来威力很大,可惜用起来不太方便,</p> <p>我封装几个,请各位测试一下:是否有误</p> <p>using System;<br />using System.Runtime.InteropServices ;<br />using HANDLE = System.IntPtr;<br />using HWND = System.IntPtr;<br />using HFILE=System.IntPtr;<br />using DWORD=System.UInt32 <br />using LPCTSTR=System.String ;<br />using LPTSTR=System.String ;<br />using LPSTR=System.String ;<br />using BOOL=System.Int32 ;<br />using UINT=System.UInt32 ;</p> <p>namespace WinApi<br />{<br />&nbsp;/// &lt;summary&gt;<br />&nbsp;/// Win32Api文件处理<br />&nbsp;/// &lt;/summary&gt;<br />&nbsp;public sealed class Win32Api_File<br />&nbsp;{<br />&nbsp;&nbsp;public const&nbsp; uint MAX_PATH=256;<br />&nbsp;&nbsp;public const&nbsp; int TRUE=1;<br />&nbsp;&nbsp;public const&nbsp; int FALSE=0;<br />&nbsp;&nbsp;#region 指定文件的标志<br />&nbsp;public const int&nbsp;&nbsp; FILE_FLAG_WRITE_THROUGH =&nbsp; unchecked((int)0x80000000);<br />&nbsp;public const int&nbsp;&nbsp; FILE_FLAG_NO_BUFFERING&nbsp; = unchecked((int)0x20000000);<br />&nbsp;public const int&nbsp;&nbsp; FILE_FLAG_RANDOM_ACCESS&nbsp;&nbsp; =unchecked((int)0x10000000);<br />&nbsp;public const int&nbsp;&nbsp; FILE_FLAG_SEQUENTIAL_SCAN =unchecked((int)0x08000000);<br />&nbsp;public const int&nbsp;&nbsp; FILE_FLAG_DELETE_ON_CLOSE =unchecked((int) 0x04000000);<br />&nbsp;public const int&nbsp;&nbsp; FILE_FLAG_BACKUP_SEMANTICS&nbsp;&nbsp; = unchecked((int) 0x02000000);<br />&nbsp;public const int&nbsp;&nbsp; FILE_FLAG_POSIX_SEMANTICS&nbsp;&nbsp;&nbsp; = unchecked((int) 0x01000000);<br />&nbsp;public const int&nbsp;&nbsp; FILE_FLAG_OPEN_REPARSE_POINT = unchecked((int) 0x00200000);<br />&nbsp;public const int&nbsp;&nbsp; FILE_FLAG_OPEN_NO_RECALL&nbsp;&nbsp;&nbsp;&nbsp; = unchecked((int) 0x00100000);<br />&nbsp;public const int&nbsp;&nbsp; FILE_FLAG_FIRST_PIPE_INSTANCE= unchecked((int) 0x00080000);<br />&nbsp;public const int&nbsp;&nbsp; FILE_FLAG_OVERLAPPED =unchecked((int) 0x40000000);//通过结构变量来保存和设置文件<br />&nbsp;&nbsp;#endregion <br />&nbsp;&nbsp;#region 指定文件的属性<br />&nbsp;public const int&nbsp;&nbsp; FILE_ATTRIBUTE_ARCHIVE =unchecked((int) 0x20);//归档<br />&nbsp;public const int&nbsp;&nbsp; FILE_ATTRIBUTE_COMPRESSED =unchecked((int) 0x800);//<br />&nbsp;public const int&nbsp;&nbsp; FILE_ATTRIBUTE_DIRECTORY = unchecked((int)0x10);//目录<br />&nbsp;public const int&nbsp;&nbsp; FILE_ATTRIBUTE_HIDDEN = unchecked((int)0x2);//隐藏<br />&nbsp;public const int&nbsp;&nbsp; FILE_ATTRIBUTE_NORMAL = unchecked((int)0x80);//正常<br />&nbsp;public const int&nbsp;&nbsp; FILE_ATTRIBUTE_READONLY =unchecked((int) 0x1);//只读<br />&nbsp;public const int&nbsp;&nbsp; FILE_ATTRIBUTE_SYSTEM = unchecked((int)0x4);//系统文件<br />&nbsp;public const int&nbsp;&nbsp; FILE_ATTRIBUTE_TEMPORARY = unchecked((int)0x100);//临时存储文件</p> <p>&nbsp;&nbsp;#endregion<br />&nbsp;public const int&nbsp;&nbsp; INVALID_HANDLE_VALUE =-1;<br />&nbsp;public const int&nbsp;&nbsp; INVALID_FILE_SIZE=unchecked((int)0xFFFFFFFF);<br />&nbsp;public const int&nbsp;&nbsp; INVALID_SET_FILE_POINTER =-1;<br />&nbsp;public const int&nbsp;&nbsp; INVALID_FILE_ATTRIBUTES =-1;<br />&nbsp;public const int&nbsp;&nbsp; File_Begin&nbsp;&nbsp; =&nbsp;&nbsp;&nbsp;&nbsp; 0;<br />&nbsp;public const int&nbsp;&nbsp; File_Current&nbsp; =&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 1;<br />&nbsp;public const int&nbsp;&nbsp; File_End&nbsp;&nbsp;&nbsp; =&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 2;<br />&nbsp;&nbsp;#region&nbsp; 指定文件的创建方式<br />&nbsp;public const int&nbsp;&nbsp; CREATE_NEW&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =&nbsp;&nbsp;&nbsp; 1;<br />&nbsp;public const int&nbsp;&nbsp; CREATE_ALWAYS&nbsp;&nbsp; =&nbsp;&nbsp;&nbsp; 2;<br />&nbsp;public const int&nbsp;&nbsp; OPEN_EXISTING&nbsp;&nbsp; =&nbsp;&nbsp;&nbsp; 3;<br />&nbsp;public const int&nbsp;&nbsp; OPEN_ALWAYS&nbsp;&nbsp;&nbsp;&nbsp; =&nbsp;&nbsp;&nbsp; 4;<br />&nbsp;public const int&nbsp;&nbsp; TRUNCATE_EXISTING =&nbsp; 5;<br />&nbsp;&nbsp;#endregion<br />&nbsp;&nbsp;#region&nbsp; 指定文件的存取模式<br />&nbsp;public const int&nbsp;&nbsp; GENERIC=0;<br />&nbsp;public const int&nbsp;&nbsp; GENERIC_READ=1;<br />&nbsp;public const int&nbsp;&nbsp; GENERIC_WRITE=2;<br />&nbsp;&nbsp;#endregion<br />&nbsp;&nbsp;#region&nbsp; 指定文件的共享模式<br />&nbsp;&nbsp;public const int&nbsp;&nbsp; File_Share_No=0;<br />&nbsp;&nbsp;public const int&nbsp;&nbsp; File_Share_Delete=0x3;<br />&nbsp;&nbsp;public const int&nbsp;&nbsp; File_Share_Read=0x1;<br />&nbsp;&nbsp;public const int&nbsp;&nbsp; File_Share_Write=0x2;<br />&nbsp;&nbsp;#endregion<br />&nbsp;&nbsp;public struct OVERLAPPED <br />&nbsp;&nbsp;{<br />&nbsp;&nbsp;&nbsp;public int Internal;<br />&nbsp;&nbsp;&nbsp;public int InternalHigh;<br />&nbsp;&nbsp;&nbsp;public int offset;<br />&nbsp;&nbsp;&nbsp;public int OffsetHigh;<br />&nbsp;&nbsp;&nbsp;public HANDLE hEvent;<br />&nbsp;&nbsp;}</p> <p>&nbsp;&nbsp;/// &lt;summary&gt;<br />&nbsp;&nbsp;/// 指定文件的安全属性<br />&nbsp;&nbsp;/// &lt;/summary&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; public struct SECURITY_ATTRIBUTES <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br />&nbsp;&nbsp;&nbsp;public int nLength;<br />&nbsp;&nbsp;&nbsp;public int lpSecurityDescriptor;<br />&nbsp;&nbsp;&nbsp;public int bInheritHandle; <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br />&nbsp;&nbsp;/// &lt;summary&gt;<br />&nbsp;&nbsp;/// Create A New File <br />&nbsp;&nbsp;/// &lt;/summary&gt;<br />&nbsp;&nbsp;/// &lt;param name="lpFileName"&gt;FileName :end with NULL&lt;/param&gt;<br />&nbsp;&nbsp;/// &lt;param name="dwDesiredAccess"&gt;Access Mode&lt;/param&gt;<br />&nbsp;&nbsp;/// &lt;param name="dwShareMode"&gt;Share&nbsp; Mode&lt;/param&gt;<br />&nbsp;&nbsp;/// &lt;param name="lpSec"&gt;文件安全属性&lt;/param&gt;<br />&nbsp;&nbsp;/// &lt;param name="dwCreationDisposition"&gt;Creat Mode&lt;/param&gt;<br />&nbsp;&nbsp;/// &lt;param name="dwFlagsAndAttributes"&gt;其值为=Flags|Attributes&lt;/param&gt;<br />&nbsp;&nbsp;/// &lt;param name="hTemplateFile"&gt;临时文件句柄可以为NULL&lt;/param&gt;<br />&nbsp;&nbsp;/// &lt;returns&gt;&lt;/returns&gt;<br />&nbsp;[DllImport("Kernel32.dll") ]<br />&nbsp;&nbsp;&nbsp;&nbsp; public extern static&nbsp; System.IntPtr CreateFile(<br />&nbsp;&nbsp;&nbsp;string lpFileName,<br />&nbsp;&nbsp;&nbsp;System.UInt32 dwDesiredAccess,<br />&nbsp;&nbsp;&nbsp;System.UInt32 dwShareMode,<br />&nbsp;&nbsp;&nbsp;ref SECURITY_ATTRIBUTES lpSec,<br />&nbsp;&nbsp;&nbsp;System.UInt32 dwCreationDisposition,<br />&nbsp;&nbsp;&nbsp;System.UInt32 dwFlagsAndAttributes,<br />&nbsp;&nbsp;&nbsp;System.IntPtr hTemplateFile<br />&nbsp;&nbsp;&nbsp;);<br />&nbsp;&nbsp;/// &lt;summary&gt;<br />&nbsp;&nbsp;/// 创建一个临时文件<br />&nbsp;&nbsp;/// &lt;/summary&gt;<br />&nbsp;&nbsp;/// &lt;param name="lpPathName"&gt;以NULL结尾的目录路径名&lt;/param&gt;<br />&nbsp;&nbsp;/// &lt;param name="lpPrefixString"&gt;临时文件名的前缀字符串(以NULL结尾)&lt;/param&gt;<br />&nbsp;&nbsp;/// &lt;param name="uUnique"&gt;为0时将返回一个唯一的整数&lt;/param&gt;<br />&nbsp;&nbsp;/// &lt;param name="lpTempFileName"&gt;接受临时文件名的缓冲区&lt;/param&gt;<br />&nbsp;&nbsp;/// &lt;returns&gt;&lt;/returns&gt;<br />&nbsp;&nbsp;[DllImport("Kernel32.dll") ]<br />&nbsp;&nbsp;&nbsp;public extern static&nbsp;&nbsp; uint&nbsp;&nbsp; GetTempFileName(<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; string lpPathName,<br />&nbsp;&nbsp;&nbsp;&nbsp; <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; string&nbsp; lpPrefixString ,<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; uint&nbsp;&nbsp; uUnique,<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ref&nbsp; string&nbsp; lpTempFileName);<br />&nbsp;&nbsp;/// &lt;summary&gt;<br />&nbsp;&nbsp;/// 为一个已打开的文件设置文件指针<br />&nbsp;&nbsp;/// &lt;/summary&gt;<br />&nbsp;&nbsp;/// &lt;param name="hFile"&gt;已经打开的文件名柄&lt;/param&gt;<br />&nbsp;&nbsp;/// &lt;param name="lDistanceToMove"&gt;文件指针要移动的byte数&lt;/param&gt;<br />&nbsp;&nbsp;/// &lt;param name="lpDistanceToMoveHigh"&gt;。。&lt;/param&gt;<br />&nbsp;&nbsp;/// &lt;param name="dwMoveMethod"&gt;移动方式:File_Begin,File_End,File_Current&lt;/param&gt;<br />&nbsp;&nbsp;/// &lt;returns&gt;&lt;/returns&gt;<br />[DllImport("Kernel32.dll") ]<br />&nbsp;&nbsp;public extern&nbsp; static&nbsp; uint SetFilePointer(<br />&nbsp;&nbsp;&nbsp;HANDLE hFile,<br />&nbsp;&nbsp;&nbsp;int&nbsp;&nbsp;&nbsp; lDistanceToMove,//number of bytes to move file pointer<br />&nbsp;&nbsp;&nbsp;ref int lpDistanceToMoveHigh, //point to high_order dword of distance to move<br />&nbsp;&nbsp;&nbsp;int dwMoveMethod//how to move<br />&nbsp;&nbsp;&nbsp;);</p> <p>&nbsp;&nbsp;/// &lt;summary&gt;<br />&nbsp;&nbsp;/// Write Data to&nbsp; File<br />&nbsp;&nbsp;/// &lt;/summary&gt;<br />&nbsp;&nbsp;/// &lt;param name="hFile"&gt;OpenFile返回 的文件句柄&lt;/param&gt;<br />&nbsp;&nbsp;/// &lt;param name="lpBuffer"&gt;要写入文件的数据地址</param>
  /// <param name="nNumberOfBytesToWrite">写入多少字节</param>
  /// <param name="lpNumberOfBytesWritten">返回本次调用成功写入的字节数</param>
  /// <param name="lpOverlapped"></param>
  /// <returns></returns>
            [DllImport("Kernel32.dll") ]
   public static extern int WriteFile(HANDLE hFile,
    IntPtr lpBuffer,
    int nNumberOfBytesToWrite,
    ref int lpNumberOfBytesWritten,
    ref OVERLAPPED lpOverlapped);
  /// <summary>
  /// 文件异步读写的回调方法 dwErrorCode==0,则I/O顺利完成
  /// </summary>
         public delegate  void   FileIOCompletionRoutine(uint dwErrorCode,
      uint  lwNumberOfBytesTrancsfer,
      ref OVERLAPPED lpOverlapped);
   [DllImport("kernel32")]
  public static extern int WriteFileEx(HANDLE hFile,
    IntPtr lpBuffer,
    int nNumberOfBytesToWrite,
    ref OVERLAPPED lpOverlapped,
    FileIOCompletionRoutine lpCompletionRoutine);
  [DllImport("kernel32")]
  public static extern int ReadFile(HANDLE hFile,
   IntPtr lpBuffer,
   int nNumberOfBytesToRead,
   ref int lpNumberOfBytesRead,
   ref OVERLAPPED lpOverlapped);
  [DllImport("kernel32")]
  public static extern int ReadFileEx(HANDLE hFile,
   IntPtr lpBuffer,
   int nNumberOfBytesToRead,
   ref OVERLAPPED lpOverlapped,
   FileIOCompletionRoutine lpCompletionRoutine);
  [DllImport("kernel32")]
  public static extern int CopyFile(string lpExistingFileName, string lpNewFileName, int bFailIfExists);
  public delegate uint  CopyProgressRoutine(long totalFileSize,
   long  totalBytesTransfer,
   long  streamSize,
   long  streamBytesTransfered,
   uint  dwStreamNumber,
   uint  dwCallbackReason,
   HANDLE hSourceFile,
   HANDLE hDestinationFile,
   System.IntPtr lpData);
  [DllImport("kernel32")]
  public static extern int  CopyFileEx(string lpExistingFileName,
   string  lpNewFileName,
   CopyProgressRoutine lpPrgRoutine,
   System.IntPtr lpData,
   ref int pbCancel,
   uint  dwCopyFlag);
  [DllImport("kernel32")]
  public static extern int MoveFile(string lpExistingFileName, string lpNewFileName);
  [DllImport("kernel32")]
  public static extern int MoveFileEx(string lpExistingFileName, string lpNewFileName, uint dwFlags);
  [DllImport("kernel32")] public static extern int DeleteFile(string lpFileName);
  [DllImport("kernel32")] public static extern int CloseHandle(HANDLE hFile);
  [DllImport("kernel32")] public static extern uint GetFileSize(HANDLE hFile, ref uint lpFileSizeHigh);
  public const int FILE_TYPE_CHAR = 0x2;
  public const int FILE_TYPE_DISK = 0x1;
  public const int FILE_TYPE_PIPE = 0x3;
  public const int FILE_TYPE_REMOTE = 0x8000;
  public const int FILE_TYPE_UNKNOWN = 0x0;
  /// <summary>
  /// 得到文件类型
  /// </summary>
  /// <param name="hFile"></param>
  /// <returns>返回以下之一: FILE_TYPE_CHAR = 0x2;
     ///   FILE_TYPE_DISK = 0x1;
  ///   FILE_TYPE_PIPE = 0x3;
     ///     FILE_TYPE_REMOTE = 0x8000;
     ///    FILE_TYPE_UNKNOWN = 0x0;</returns>
  [DllImport("kernel32")] public static extern uint GetFileType(HANDLE hFile);
  public struct FILETIME
  {
   uint dwLowDateTime;
   uint  dwHighDateTime;
  }
  [DllImport("kernel32")] public static extern int SetFileTime(HANDLE hFile, ref FILETIME lpCreationTime, ref FILETIME lpLastAccessTime, ref FILETIME lpLastWriteTime);
  [DllImport("kernel32")] public static extern int GetFileTime(HANDLE hFile, ref FILETIME lpCreationTime, ref FILETIME lpLastAccessTime, ref FILETIME lpLastWriteTime);
  #region 文件格式执行类型
  public const int SCROLLLOCK_ON = 0x40;
  public const int SCS_32BIT_BINARY = 0;
  public const int SCS_DOS_BINARY = 1;
  public const int SCS_OS216_BINARY = 5;
  public const int SCS_PIF_BINARY = 3;
  public const int SCS_POSIX_BINARY = 4;
  public const int SCS_WOW_BINARY = 2;
  #endregion
  [DllImport("kernel32")] public static extern int GetBinaryType(string lpAppName,
   ref uint  lpBinaryType);
  [DllImport("kernel32")]
  public static extern  DWORD GetFullPathName(
     LPCSTR lpFileName,
        DWORD nBufferLength,
        out  LPSTR lpBuffer,
        out  LPSTR lpFilePart);
  [DllImport("kernel32")] public static extern int GetShortPathName(string lpszLongPath, string lpszShortPath, uint cchBuffer);
  public struct BY_HANDLE_FILE_INFORMATION
  {
  uint  dwFileAttributes;
  FILETIME ftCreationTime;
  FILETIME ftLastAccessTime;
  FILETIME ftLastWriteTime;
  uint  dwVolumeSerialNumber;
  uint  nFileSizeHigh;
  uint  nFileSizeLow;
  uint  nNumberOfLinks;
  uint  nFileIndexHigh;
  uint  nFileIndexLow;
 }
  [DllImport("kernel32")]
  public static extern  BOOL  GetFileInformationByHandle(
    HANDLE hFile,
    out BY_HANDLE_FILE_INFORMATION lpFileInformation );
  [DllImport("kernel32")]
  public static  extern BOOL  SetEndOfFile(HANDLE file);
  [DllImport("kernel32")]
  public static  extern BOOL  SetFileAttribute(
   LPCTSTR lpFileName,
   DWORD   dwFileAttribute);
  /// <summary>
  /// 返回文件的属性
  /// </summary>
  /// <param name="lpFileName"></param>
  /// <returns>如果返回0xFFFFFFFF返回失败</returns>
  [DllImport("kernel32")]
  public static  extern  DWORD  GetFileAttribute(
   LPCTSTR lpFileName);
  [DllImport("kernel32")]
  public static  extern  BOOL CreateDirectoryA(
     LPCSTR lpPathName,
            ref SECURITY_ATTRIBUTES lpSecurityAttributes);
  [DllImport("kernel32")]
  public static  extern  BOOL CreateDirectoryA(
   LPCSTR lpTemplateName,
   LPCSTR lpNewDirectory,
   ref SECURITY_ATTRIBUTES lpSecurityAttributes
   );
  [DllImport("kernel32")]
  public static  extern  BOOL RemoveDirectory( LPCSTR lpPathName);
  [DllImport("kernel32")]
  public static  extern  UINT GetSystemDirectory(out LPTSTR lpBuffer,  UINT uSize);
  [DllImport("kernel32")]
  public static  extern  DWORD GetTempPath( DWORD nBufferLength,out LPSTR lpBuffer );
  [DllImport("kernel32")]
  public static  extern  UINT GetWindowsDirectory(out  LPSTR lpBuffer, UINT uSize);
  [DllImport("kernel32")]
  public static extern     BOOL   SetCurrentDirectory(LPCTSTR lpPathName);
  [DllImport("kernel32")]
  public static extern DWORD  GetCurrentDirectory(int nBufferLength, LPTSTR lpBuffer);
  public struct WIN32_FIND_DATA
  {
   public int dwFileAttributes;
   public FILETIME ftCreationTime;
   public FILETIME ftLastAccessTime;
   public FILETIME ftLastWriteTime;
   public int nFileSizeHigh;
   public int nFileSizeLow;
   public int dwReserved0;
   public int dwReserved1;
   [MarshalAs(UnmanagedType.ByValTStr, SizeConst=Win32Api_File.MAX_PATH )]
   public string cFileName;
   [MarshalAs(UnmanagedType.ByValTStr, SizeConst=14)]
   public string cAlternate;
  }
  [DllImport("kernel32")]
  public static extern  HANDLE FindFirstFile(LPCTSTR lpFileName,ref WIN32_FIND_DATA lpFindFileData);
  [DllImport("kernel32")]
  public static extern  BOOL  FindNextFile(HANDLE hFindFile,ref WIN32_FIND_DATA lpFindFileData);
  [DllImport("kernel32")]
  public static extern DWORD SearchPath(LPCTSTR lpPath,
      LPCTSTR lpFileName,
      LPCTSTR lpExtension,
      DWORD nBufferLength,
      LPTSTR  lpBuffer,
      ref LPTSTR  lpFilePart);
  [DllImport("kernel32")]
  public static extern  BOOL  FindClose(HANDLE hFindFile);
  [DllImport("kernel32")]
  public static extern BOOL  GetDiskFreeSpace(
     LPCTSTR lpRootPathName,
     ref DWORD lpSectorsPerCluster,
     ref DWORD lpbytesPerSector,
     ref DWORD lpNumberOfFreeClusters,
     ref DWORD lpTotalNumberOfCluster);
  [DllImport("kernel32")]
  public static extern BOOL  GetDiskFreeSpaceEx(
     LPCTSTR lpDirectoryName,
     ref long  lpFreeBytesAalToCaller,
     ref long  lpTotalNumberOfBytes,
     ref long  lpTotalNumberOfFreeBytes);
public const  int DRIVE_UNKNOWN =    0;
public const  int DRIVE_NO_ROOT_DIR= 1;
public const  int DRIVE_REMOVABLE =  2;
public const  int DRIVE_FIXED   =    3;
public const  int DRIVE_REMOTE   =   4;
public const  int DRIVE_CDROM     =  5;
public const  int DRIVE_RAMDISK   =  6;
  /// <summary>
  /// 得到磁盘类型
  /// </summary>
  /// <param name="lpRootPathName">可选参数</param>
  /// <returns>  0。。。6</returns>
  [DllImport("kernel32")]
  public static extern  UINT GetDriveType(
     LPCSTR  lpRootPathName);
 


 
 
 


 

  

  

 

 

 
                                                   
  private Win32Api_File()
  {
   //
   // TODO: 在此处添加构造函数逻辑
   //
  }
 }
}


 

C#调用Win32 api学习总结

从.NET平台调用Win32 API         Win32 API可以直接控制Microsoft Windows的核心,因为API(Application Programming Inte...
  • bcbobo21cn
  • bcbobo21cn
  • 2016年03月19日 11:39
  • 4005

win32 API函数大全

【1】. API之网络函数  WNetAddConnection :创建同一个网络资源的永久性连接  WNetAddConnection2 :创建同一个网络资源的连接  WNetAddConne...
  • hellokandy
  • hellokandy
  • 2016年06月29日 19:37
  • 3773

Java调用win32API与DLL的使用

之前一直觉得Java不能调用系统API就是一个莫大的遗憾,后来发现,我错了,还真可以的,下面就由小桩带你研究研究,如果你会会C++当然最好,学习Java的都知道,Java是跨平台的语言,需要虚拟机,J...
  • GLGoober
  • GLGoober
  • 2017年03月05日 08:47
  • 577

Java调用win32API与DLL的使用

之前一直觉得Java不能调用系统API就是一个莫大的遗憾,后来发现,我错了,还真可以的,下面就由小强带你研究研究,如果你会会C++当然最好,学习Java的都知道,Java是跨平台的语言,需要虚拟机,J...
  • shenjianxz
  • shenjianxz
  • 2016年08月16日 14:08
  • 2905

Python使用win32api系统钩子

有这样一个需求:客户的测试程序扫描一个产品的条形码,但是它没有和系统验证的功能(就是从系统里面检查是否可以在此测试位进行测试。比如说有10个测试位,这是第4个,那么就必须前面的3个测试位全部pass后...
  • liuyukuan
  • liuyukuan
  • 2016年10月30日 22:57
  • 3527

LuaJIT通过ffi调用win32 API完成窗口版HelloWorld示例

看网上关于LuaJIT调用Win32 API函数的示例除了蹦对话框,就是调一些简单的修改标题之类的函数来演示…… 就不能绘制一个完整的窗口,有一个完整的消息循环么? 所以说,这种没人去干的事,当然就有...
  • yimengqiannian
  • yimengqiannian
  • 2016年12月16日 20:08
  • 993

Win32 API 串口编程

目录 一串口通信基础       1.1串口通信原理与特点      1.2串口通信的传输方式      1.3串口通信的同步技术      1.4串行接口标准      二 API函数实现串口通信 ...
  • changyourmind
  • changyourmind
  • 2016年08月09日 11:22
  • 1563

Windows编程 Win32API中常见的数据类型

Win32API有一套和C\C++基本数据类型不同的数据类型. C\C++语言的数据类型有如下几个缺陷: 数据类型平台相关,在不同平台上,同一个数据类型可能占用不同的空间大小。典型的,在16位系...
  • RitMan
  • RitMan
  • 2015年12月31日 15:20
  • 2340

老外的一个为VB.NET和VB提供WIN32 API在线查询和用法的站,给VB.NET的朋友推荐下

老外的一个为VB.NET和VB提供WIN32 API在线查询和用法的站,给VB.NET的朋友推荐下 以前用VB做开发的时候有个VB WIN32API手册(window api函数手册),CHM格式的,...
  • qzmrock
  • qzmrock
  • 2013年09月11日 16:59
  • 4644

图解C# 调用Win32 API 示例程序

先上代码;相关函数不解释;网上比较容易查到; using System; using System.Collections.Generic; using System.ComponentModel; ...
  • bcbobo21cn
  • bcbobo21cn
  • 2016年04月21日 22:18
  • 1017
内容举报
返回顶部
收藏助手
不良信息举报
您举报文章:常用Win32Api调用............
举报原因:
原因补充:

(最多只允许输入30个字)