zoukankan      html  css  js  c++  java
  • Windows API 第三篇

    1.获得程序自身的路径:

    DWORD GetModuleFileName(
      HMODULE hModule,    // handle to module
      LPTSTR lpFilename,  // path buffer
      DWORD nSize         // size of buffer
    );
    参数说明:
    hModudle :[in] Handle to the module whose path is being requested. If this parameter is NULL, GetModuleFileName retrieves the path for the current module.
    lpFilename: [out] Pointer to a buffer that receives the fully-qualified path for the module. If the length of the string exceeds the size specified by the nSize parameter, the string is truncated.
    nSize:[in] Specifies the length of the lpFilename buffer, in TCHARs.

    返回值:

    If the function succeeds, the return value is the length of the string copied to the buffer, in TCHARs.

    If the function fails, the return value is zero. To get extended error information, call GetLastError.

    2. 获取windows目录

    UINT GetWindowsDirectory(
      LPTSTR lpBuffer,  // buffer for Windows directory
      UINT uSize        // size of directory buffer
    );
    参数说明:
    lpBuffer: [out] Pointer to the buffer to receive the null-terminated string containing the path. This path does not end with a backslash unless the Windows directory is the root directory. For example, if the Windows directory is named Windows on drive C, the path of the Windows directory retrieved by this function is C:Windows. If the system was installed in the root directory of drive C, the path retrieved is C:
     uSize:  [in] Specifies the maximum size, in TCHARs, of the buffer specified by the lpBuffer parameter. This value should be set to MAX_PATH+1 to allow sufficient space for the path and the null terminator. 

    返回值:
    f the function succeeds, the return value is the length, in TCHARs, of the string copied to the buffer, not including the terminating null character. If the length is greater than the size of the buffer, the return value is the size of the buffer required to hold the path.If the function fails, the return value is zero. To get extended error information, call GetLastError.

    3. 获取系统目录
    UINT GetSystemDirectory( LPTSTR lpBuffer, // buffer for system directory UINT uSize // size of directory buffer );
    参数说明:
    lpBuffer
    [out] Pointer to the buffer to receive the null-terminated string containing the path. This path does not end with a backslash unless the system directory is the root directory. For example, if the system directory is named WindowsSystem on drive C, the path of the system directory retrieved by this function is C:WindowsSystem.
    uSize:[in] Specifies the maximum size of the buffer, in TCHARs. This value should be set to at least MAX_PATH+1 to allow sufficient space for the path and the null terminator.

    返回值判断:

    If the function succeeds, the return value is the length, in TCHARs, of the string copied to the buffer, not including the terminating null character. If the length is greater than the size of the buffer, the return value is the size of the buffer required to hold the path.

    If the function fails, the return value is zero. To get extended error information, call GetLastError.

  • 相关阅读:
    PHP学习路径及练手项目合集
    Java学习路径及练手项目合集
    Pandas 常见的基本方法
    MAC 下配置MQTT 服务器Mosquitto
    MQTT 在 mac 上搭建
    Git学习--版本回退
    Git学习--创建版本库
    js判断是否在微信浏览器中打开
    微信浏览器HTTP_USER_AGENT判断
    XXX.APP已损坏,打不开.你应该将它移到废纸篓
  • 原文地址:https://www.cnblogs.com/priarieNew/p/9753937.html
Copyright © 2011-2022 走看看