_beginthreadex instead of CreateThread or visa versa
_beginthreadex() internally calls CreateThread for creating thread. In addition to creating thread, it will perform some CRT initializations also. So if you want to call some CRT functions inside the new thread, its better to use the _beginthreadex() function.
The Value return from GetCurrentthreadId and GetCurrentThread
GetCurrentthreadId return the current thread ID where GetCurrentThread return the handle to current Thread.
handle The GetCurrentthread API returns -1
If you call the GetCurrentthread(), it will always return 0xfffffffe. Actually this is a pseudo handle to the current thread. This value can be used only in that thread. The GetCurrentProcess() also returns a similar value - 0xffffffff.
If you want to get the correct handle value, you need to use the DuplicateHandle() function
HANDLE hRealHandle = 0;
DuplicateHandle( GetCurrentProcess(), // Source Process Handle.
GetCurrentThread(), // Source Handle to dup.
GetCurrentProcess(), // Target Process Handle.
&hRealHandle, // Target Handle pointer.0, // Options flag.
TRUE, // Inheritable flag
DUPLICATE_SAME_ACCESS );// Options
Unfortunately you are correct that those messages are indistinguishable. SendInput() inserts the input messages directly into the kernel input stream. You can read one of my prior posts[^] regarding how SendInput is actually invoking a privileged system call. [^]
If there is a security reason as to why you want to block this function then the only way I can think of is a driver implementing a SYSENTER hook[^].
I am having trouble capturing the mouse wheel messages. Everything works except when WM_MOUSEWHEEL is called, the HIWORD of wParam (combination of WHEEL_DELTAs, positive value means wheel is moved away from the user, negative is towards) is always 0. What is the problem? I am using Visual Studio 2003 btw.
// mousehook.cpp : Defines the entry point for the application.
The high-order word indicates the distance the wheel is rotated, expressed in multiples or divisions of WHEEL_DELTA, which is 120. A positive value indicates that the wheel was rotated forward, away from the user; a negative value indicates that the wheel was rotated backward, toward the user.
so ((short)HIWORD(wParam)) should give me what i want, but it gives me 0 all the time.
The TRACE is just something to use in MFC apps. If you don't use MFC, just ignore it and use printf or something of the sort. I was just trying to demonstrate the value of zDelta and needed an output mechanism.
There are LOTS of utilities (executables) for mounting ISO files to drive letters, but I want to open and read the contents of an ISO file through some kind of library, not a separate EXE. Any way to do that? I don't mind mind mounting the ISO to a drive letter or directory, I just don't want to make the user do it manually.
It's not that critical, just a "nice to have" for my app. Besides, if it was that easy, it seems like there would already be a free code library available for this. Heck, my boss may even be willing to pay a reasonable price for one.
Hi, I added code for supporting multiple languages and are suprised about the following behaviour of Windows XP.
I have an English Windows version and selected English (United Kingdom) as my user interface language, I verified this in Control Panel -> Regional and Language Options. The function GetUserDefaultUILanguage from kernel32.dll returns 0x0409 (ENU, United States) and GetSystemDefaultLangID returns 0x0809 (ENG, United Kingdom)... shouldn't they both return the same?
GetSystemDefaultLangID() returns the system locale. This is used to determine which code page is used for non-Unicode (aka "ANSI") text on a system. It can be changed (on XP) from the advanced tab on the "regional and language options" in Control Panel (probably needs to be rebooted before the change takes effect)
returns the current UI language which can be set by a user if MUI pack is installed.
Thanks for the info. What I don't understand that if I detect the language according to MSDN[^] then I would detect the wrong language (in a case where both UK and US language resources are available for an application).
GetUserDefaultUILanguage() Win32 API: 0x0409 US English GetSystemDefaultUILanguage() Win32 API: 0x0409 US English GetSystemDefaultLangID() Win32 API: 0x0809 UK English
What would be the correct order in an application to check?