函数学习

①GetModuleFileName:获取模块的完整路径

The GetModuleFileName function retrieves the full path and filename for the executable file containing the specified module.


DWORD GetModuleFileName(
  HMODULE hModule,    // handle to module to find filename for
  LPTSTR lpFilename,  // pointer to buffer to receive module path
  DWORD nSize         // size of buffer, in characters
);


hModule
Handle to the module whose executable filename is being requested. If this parameter is NULL,GetModuleFileName returns the path for the file used to create the calling process.
lpFilename
Pointer to a buffer that is filled in with the path and filename of the given module.
nSize
Specifies the length, in characters, of the lpFilename buffer. If the length of the path and filename exceeds this limit, the string is truncated.
Return Values

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

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

Remarks

If a module is loaded in two processes, its module filename in one process may differ in case from its module filename in the other process.

system, _wsystem

Execute a command.

int system( const char *command);

int _wsystem( const wchar_t *command);

Parameter

command

Command to be executed

Remarks

The system function passes command to the command interpreter, which executes the string as an operating-system command.system refers to theCOMSPEC andPATH environment variables that locate the command-interpreter file (the file named CMD.EXE in Windows NT). Ifcommand is NULL, the function simply checks to see whether the command interpreter exists.

③GetCurrentDirectoryA()

获取当前的工作目录,注意,当你用VC编译源码的时候,该函数获取的工作目录是包含.cpp文件的目录,而当你编译完成之后去运行可执行文件的时候,获取的工作目录却是包含可执行文件的目录。

 

//将一个路径与一个文件名合成路径

PathCombineW(&pszPath, pszPrefix, *(LPCWSTR *)file_name)

//检查路径的前缀

PathIsPrefixW(pszPrefix, &pszPath)

//路径去文件名

PathRemoveFileSpecW(&pszPath)

//另一个创建目录的函数

SHCreateDirectoryExW(0, pszPath, 0)

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值