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.

  • 相关阅读:
    GNU GRUB 2:系统引导器的领导者
    Javascript 返回上一页并刷新
    返回代表指定日期的指定日期部分的整数。返回当前周
    请问如何获取字符串在数组中的位置
    SQL终极优化(包括很多非索引方面的优化和原理)
    td onmouseover="this.style.cursor='hand'" onmouseout="this.style.cursor='normal'" >小手状
    树形菜单
    分页 的首页 rs.absoluteposition=rs.absoluteposition+2+((abs(wzpage)1)*wzrep) 要加2 ??
    JS只弹出一个居中弹出窗口
    一个真实的项目经历,很多东西大家可以借鉴下
  • 原文地址:https://www.cnblogs.com/priarieNew/p/9753937.html
Copyright © 2011-2022 走看看