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 Windows\System on drive C, the path of the system directory retrieved by this function is C:\Windows\System.
- 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.
Windows API 第三篇的更多相关文章
- windows API 第22篇 WTSGetActiveConsoleSessionId
函数原型:DWORD WTSGetActiveConsoleSessionId (VOID)先看一下原文介绍: The WTSGetActiveConsoleSessionId function re ...
- Windows API 第19篇 FindFirstVolumeMountPoint FindNextVolumeMountPoint
相关函数:HANDLE FindFirstVolumeMountPoint( ...
- windows API 第13篇 MoveFileEx
上一篇介绍了MoveFile,这次分析MoveFileEx,它是MoveFile的扩展函数,功能还要更加强大些.先看定义: BOOL WINAPI MoveFileEx( _In_ LPCTS ...
- Windows API 第六篇 GetLocalTime
GetLocalTime获取系统时间信息.函数原型:VOID WINAPI GetLocalTime( __out LPSYSTEMTIME lpSystemTime ); 先来看S ...
- Windows API 第21篇 DeleteVolumeMountPoint 删除挂载点
函数原型:BOOL DeleteVolumeMountPoint( LPCTSTR lpszV ...
- Windows API 第20篇 SetVolumeMountPoint 设置卷挂载点参数错误
函数原型:BOOL SetVolumeMountPoint( IN LPCTSTR lpszVo ...
- Windows API 第20篇 GetVolumeNameForVolumeMountPoint
函数原型: BOOL GetVolumeNameForVolumeMountPoint( ...
- windows API 第 18篇 FindFirstVolume FindNextVolume
函数定义:Retrieves the name of a volume on a computer. FindFirstVolume is used to begin scanning the vol ...
- Windows API 第17篇 GetLogicalDriveStrings 获取本机所有逻辑驱动器,以根目录的形式表示
函数原型:DWORD GetLogicalDriveStrings( DWORD nBufferLength, // size of buffer ...
随机推荐
- Yii2 中使用ts
在运行环境 vagrant Ubuntu box 中安装 sass ,typescript等 安装需要的软件: sudo su -c "gem install sass" # 可选 ...
- Monkey 稳定性测试
学习网址: https://blog.csdn.net/lucytan01/article/details/79958727 https://blog.csdn.net/hebbely/article ...
- mysql 存储过程学习 汇总
存储过程框架 DEMILITER $$ -- 重定义符 DROP PROCEDURE IF EXISTS store_procedure$$ -- 如果存在此名的存储过程,先删除 CREATE PRO ...
- MediatR 知多少 - 简书
原文:MediatR 知多少 - 简书 引言 首先不用查字典了,词典查无此词.猜测是作者笔误将Mediator写成MediatR了.废话少说,转入正题. 先来简单了解下这个开源项目MediatR(作者 ...
- 一个很笨的方法,写脚本来实现自动调dmp,找有用的数据
很久很久以前用到的方法, 方法挺笨的,但是算是比较实用吧. 全自动的调试dmp,最后只要结果. 谁用得着就给谁看吧. 这里需要两个脚本 1:启动脚本,是一个批处理文件,用来启动调试器,来加载dmp和调 ...
- Oracle批量更改用户下表空间
--查询某个用户下的表,并生成一个修改其命名空间的批处理语句 select 'alter table '|| table_name ||' move tablespace 要迁入的表空间;' from ...
- 2019-5-29-Roslyn-让-VisualStudio-急速调试底层库方法
title author date CreateTime categories Roslyn 让 VisualStudio 急速调试底层库方法 lindexi 2019-5-29 20:2:9 +08 ...
- 2019-8-30-PowerShell-通过-WMI-获取系统安装的驱动
title author date CreateTime categories PowerShell 通过 WMI 获取系统安装的驱动 lindexi 2019-08-30 08:58:39 +080 ...
- 编写Reduce处理逻辑
- 创建 linuxrc 文件
创建 linuxrc,加入如下内容: [arm@localhost my_rootfs]#vi linuxrc #!/bin/sh #挂载/etc 为 ramfs, 并从/mnt/etc 下拷贝文件到 ...