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.

最新文章

  1. (转)Intent flag 与启动模式的对应关系
  2. Codeforces Round #210 (Div. 2) C. Levko and Array Recovery
  3. OrderSessionHelper查看订单在session是否存在的辅助类
  4. 开发中可能会用到的几个 jQuery 小提示和技巧(转)
  5. bat文件的妙用1-一键开启所有开发软件
  6. LA 3902 Network(树上最优化 贪心)
  7. easyui之combotree
  8. 二、Cocos2dx概念介绍(游戏开发中不同的坐标系,cocos2dx锚点)
  9. Uncaught TypeError: Cannot read property 'call' of undefined jquery.validate.min.js:28
  10. erlang dets
  11. Linux学习——yum学习和光盘yum源搭建
  12. System包含的信息
  13. spring-boot-starter-actouator2.1.4与c3p0版本0.9.1.2冲突
  14. Vue(三十二)SSR服务端渲染Nuxt.js
  15. 【转】Java并发编程:如何创建线程?
  16. PHP异步扩展Swoole笔记(1)
  17. Python的hasattr(),getattr(),setattr()
  18. day4:数据结构list
  19. yield return:使用.NET的状态机生成器
  20. React Native API之 ActionSheetIOS

热门文章

  1. BeanPostProcessor原理学习
  2. java中的break continue
  3. JavaScript中的文档对象模型
  4. System.Web.Mvc.IController.cs
  5. vue 绑定多个class
  6. JVM 内存模型及垃圾回收
  7. 6_2.springboot2.x整合Druid和配置数据源监控
  8. NoSQL SimpleDB
  9. js闭包与java内部类
  10. AutoIt自动化编程(1)【转】