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.

  • 相关阅读:
    svn版本更新
    前端复选框的全选与获取数据
    关于博主的职业生涯历程
    Presto部署指南
    linux下简单好用的端口映射转发工具rinetd
    阿里云时间服务器
    mongodb常用操作
    mysql常用操作
    mysql内存分配问题
    zabbix微信发送消息脚本
  • 原文地址:https://www.cnblogs.com/priarieNew/p/9753937.html
Copyright © 2011-2022 走看看