关于XP没有QueryFullProcessImageName的问题(in ProcessInfo)

2011-03-29

记得以前看过一点儿windows核心编程,现在又拿起来重新看看,哎,基本上都忘了。简单看了看进程那部分,自己想写点关于进程的小程序,不过后来发现原来书配了源代码的。于是下到http://www.wintellect.com/books.aspx 把代码下了。打开,然后一切顺利,编译全部通过。不过执行ProcessInfo时,出现错误了。无法定位程序输入点QueryFullProcessImageNameW于KERNEL32.dll上 。去google了一下,原来是XP里面没有QueryFullProcessImageNameW这个东东啊。随后查了查msdn,上面说

 


 

Requirements

Minimum supported client

Windows Vista

Minimum supported server

Windows Server 2008

Header

Winbase.h (include Windows.h)

 


 

 

原来自己用的是XP,不满足人家最小要求啊,呵呵:)。接着往后看,有一个评论说:

 


 

For the best results use the following table to convert paths.

Windows 2000 = GetModuleFileName()
Windows XP x32 = GetProcessImageFileName()
Windows XP x64 = GetProcessImageFileName()
Windows Vista = QueryFullProcessImageName()
Windows 7 = QueryFullProcessImageName()


Note: If you are not aware the API GetProcessImageFileName() returns a kernel DOS device path. You can use the following API to map the device paths to a Win32 format.

GetLogicalDriveStrings
QueryDosDevice

 


原来32位XP还可以用GetProcessImageFileName呢。又查了下GetProcessImageFileName

DWORD WINAPI GetProcessImageFileName(
  __in   HANDLE hProcess,
  __out  LPTSTR lpImageFileName,
  __in   DWORD nSize
);
把源码改了改,如下:

再加上psapi.h这个头文件,然后编译要是有错,5555。 error   LNK2001:   unresolved   external   symbol 。???怎么会有这个问题呢,又看了下msdn,原来

Requirements

Minimum supported client

Windows XP

Minimum supported server

Windows Server 2003

Header

Psapi.h

Library

Kernel32.lib on Windows 7 and Windows Server 2008 R2, Psapi.lib if PSAPI_VERSION=1 on Windows 7 and Windows Server 2008 R2, Psapi.lib on Windows Server 2008, Windows Vista, Windows Server 2003, and Windows XP/2000

DLL

Kernel32.dll on Windows 7 and Windows Server 2008 R2, Psapi.dll if PSAPI_VERSION=1 on Windows 7 and Windows Server 2008 R2, Psapi.dll on Windows Server 2008, Windows Vista, Windows Server 2003, and Windows XP/2000
 
 
原来是自己没有仔细看啊,少了个psapi.lib啊,难怪啊。加上之后,哈哈可以运行啦,不写了,自己慢慢看看他是怎么写的,嘿嘿,顺便自己瞎改改。


 

 

 

 

 

 

 

 


评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值