现在的位置: 首页 > 综合 > 正文

常用Win32Api调用…………

2013年02月08日 ⁄ 综合 ⁄ 共 15537字 ⁄ 字号 评论关闭

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


偷笑我爱北京天安门偷笑


偷笑天安门上太阳升偷笑


偷笑伟大领袖毛主席偷笑


偷笑指引我们向前进偷笑

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

<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: 在此处添加构造函数逻辑
   //
  }
 }
}

 

抱歉!评论已关闭.