在XP系統上出現無法定位程式輸入焦點 K32GetProcessMemoryInfo

來源:互聯網
上載者:User

標籤:windows 7   windows   補丁   vc   xp   

在XP系統上出現無法定位程式輸入焦點 K32GetProcessMemoryInfo


VC2012升級補丁5.0之後,編譯出來的程式發現在XP系統無法定位程式輸入焦點 K32GetProcessMemoryInfo於動態連結程式庫kernel32.dll之上。
之前程式一直在XP上安裝正常,今天測試組的同事突然發現,新發布的版本不能在XP上使用,這個問題比較奇怪,因為以往的
版本都是沒有問題的。為什麼會突然出現這個問題呢?一開始就去尋找是否所有工程都使用V110_XP來編譯,找完所有工程都沒
出錯。最後才想到近來升級VC2012的Update5.0的補丁,再打包編譯之後,才發現XP的電腦不能使用了。


經過尋找分析,發現是如下問題:
這是由於GetProcessMemoryInfo在不同系統版本號碼不同導致的,官方說明如下:
Remarks
Starting with Windows 7 and Windows Server 2008 R2, Psapi.h establishes version numbers for the PSAPI functions. The PSAPI version number affects the name used to call the function and the library that a program must load.
If PSAPI_VERSION is 2 or greater, this function is defined as K32GetProcessMemoryInfo in Psapi.h and exported in Kernel32.lib and Kernel32.dll. If PSAPI_VERSION is 1, this function is defined as GetProcessMemoryInfo in Psapi.h and exported in Psapi.lib and Psapi.dll as a wrapper that calls K32GetProcessMemoryInfo.
Programs that must run on earlier versions of Windows as well as Windows 7 and later versions should always call this function as GetProcessMemoryInfo. To ensure correct resolution of symbols, add Psapi.lib to the TARGETLIBS macro and compile the program with -DPSAPI_VERSION=1. To use run-time dynamic linking, load Psapi.dll.


解決方案:
只需要在#include <psapi.h>引用前添加
#ifndef PSAPI_VERSION
#define PSAPI_VERSION 1
#endif
#include <psapi.h>
#pragma  comment(lib,"Psapi.lib")


看來微軟已經不支援XP系統了,因此所有發布的新版本軟體已經不再測試XP的相容性了。看來明年,也需要轉向不支援XP系統了,否則需要投

入的測試成本和維護成本急劇上升中,需要全面轉向WIN7和WIN10系統的支援。有此可見,生態系統就是這麼重要的事情,可以左右大局。




蔡軍生 號: shenzhencai  深圳

著作權聲明:本文為博主原創文章,未經博主允許不得轉載。

在XP系統上出現無法定位程式輸入焦點 K32GetProcessMemoryInfo

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.