简体   繁体   中英

GlobalAddAtom() returns 0 and GetLastError = 0x5 on Win7, works on XP

Simple code:

ATOM atom = GlobalAddAtom(L"TestCpp1"); 

It returns 0 and GetLastError returns 0x5 (Access Denied). Nothing on MSDN about it. This is on Win7. Admin rights make no difference.

Same code works on XP. AddAtom (local) works on Win7.

What's causing this?

Is this a GUI or Console application? One thing you might try is to explicity call LoadLibrary("User32") before calling GlobalAddAtom.

Here is a reference to someone that had a similar problem, on XP maybe this is relevant? http://www.tech-archive.net/Archive/Development/microsoft.public.win32.programmer.kernel/2004-03/0851.html

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM