winapi

Determine thread which holds the lock on file

Hi, I know there is no WINAPI which would do it, but if a thread is hung and holds an open handle of file. how do we determine the thread id and Terminate it within our processes. I'm not talking about releasing file locks in other processes but within my own process. it could also be possible that thread has crashed / terminated with...

Automating GUI with Win32::GuiTest /other module

I have a Win32 Gui Application is there any way with Win32::GuiTest/or any other cpan module to automate this action : intercepting the keyboad sent by the user and change it then send it to the application ,if yes could someone show some example ? ...

C++ Win32 API Controls messages

Hi, im starting with Win32 api, im adding a button control to my main window with the flowing code: HWND boton = CreateWindow( "BUTTON", // "Caption", // WS_TABSTOP | WS_VISIBLE | WS_CHILD | BS_DEFPUSHBUTTON, // Styles. 250, // x position. 10, // y position. 100, // Button width...

WMI vs Windows APIs

There are any advantages or disadvantages of using the WMI instead of Windows API to access to the information of the system? as speed, additional permissions, memory usage. or depends on the WMI class and how the WMI implements the access to the information? ...

Locate windows according to system screen size in win32 programming

Hello I have creating one window using "CreateWindow".But is there any api which can give system screen height and width of the system. So that it will very helpful to locate windows according to the system screen. Thanks & Regards, KamalBhr. ...

How to use the secure desktop in Windows Vista and W7?

Windows Vista added a new feature called the "Secure Desktop". It looks great and really draws the user's attention. But now, I want to use this desktop in my .NET/C# or Delphi/WIN32 application. And use it for my own dialog, which will ask the user for about 5 different but sensitive pieces of information. Is there a way to use it in ....

WTSQueryUserToken Fails, getlasterror() returns 1723

I have a windows service that is running under the credentials of the system account. The service periodically polls windows for the active console session id, i.e. the interactive logged in windows user, and then retrieves the user token associated with the active console session id by pinvoking the wtsapi32.dll function WTSQueryUserTok...

Transferring Win32 API WndProc Key messages from one window to the other

Hello, I'm developing for Windows Mobile in C++, and i'm running into a problem - I added my window class, and in it i handle the keyboard input with my WndProc implementation. The problem is that i'm getting the wrong codes, and identifying keys such as the func key incorrectly. And to make it worse, the values i'm getting (the wParam o...

Why might IsDialogMessage() never return?

I am debugging an application which, in its message loop, calls IsDialogMessage(). Occasionally, IsDialogMessage() never returns (where never is an interval greater than 1 hour). Based on the symbols for user32.dll available from Microsoft's symbol server, it appears to be stuck in GetNextDlgGroupItem() (or an internal variant of the s...

Can I put try / catch around an OS API that crashes?

I use a Windows OS library to manipulate image files. Sometimes it crashes deep inside it for no apparent reason—all the inputs are reasonable and its not a threading issue. The crash is memory A/V. So, what are the down sides to something like this: try { pFoo = OsAPIThatCrashes(); } catch { pFoo = NULL; } Will that even work?...

How to know if my program crashed the last time it ran?

If my program doesn't tear down correctly, the system becomes unstable. There is no workaround really. So, should my program crash and not tear down correctly, then I need to tell the user when he tries to run it again that the system was left in an unstable state. Is the right way to do this is to create a lock file when I start and del...

Find out if computer rebooted since the last time my program ran?

How can my program know if windows rebooted since the last time it ran? All versions of windows XP and on. ...

default WM_DESTROY not properly cleaning up child windows

I have a WTL 8.0 SDI application for Windows Mobile 5. In this contrived example below, I create a view, destroy it, then re-create it. But, when it's re-created assertions in the WM_INITDIALOG handler fail because the control's HWND isn't valid. I note that I can fix this by handling WM_DESTROY in CMyView and manually destroying every ...

Transferring Win32 API WndProc Key messages from one window to the other OR keyboard problem with Windows Mobile Win32 API

Hi - I'm posting this question again - as i got some potentially useful comments on my question, but unfortunately when i replied to the comments i got no answers. It seems that unless i post the question again, no one will look at it. Sorry if this is against StackOverFlow moral code - If it is - Then what is the way to resurface a ques...

How to get performance data from a remote computer using Delphi

Hi Given that I have the appropriate rights, how can I get performance data (ie. 'Pages/Sec', 'Avg. Disk Queue' and so on) from a remote computer? Basically I want to write a function like this: function GetPerformanceData(aComputerName, aPerformanceIndicator: string): variant; It is preferably (of course) to work out of the box on ...

how to create a round/circular button in win32 API using visual c++

I have a Window (win32 API) Application in visual c++. I am not using MFC. I have to create a round/circular button with bitmap image. My application have a skined view. Can any one help me out in achieving this task. Thanks in advance. ...

How to run an Application on windows start up in win32 API using visual c++

I have a Window (win32 API) Application in visual c++. I am not using MFC. I have to run my application on windows start up. I am using windows 7 and visual studio 2008. Can any one help me out in achieving the above task? Thanks in advance. ...

What happens when QueryPerformanceCounter is called?

I'm looking into the exact implications of using QueryPerformanceCounter in our system and am trying to understand it's impact on the application. I can see from running it on my 4-core single cpu machine that it takes around 230ns to run. When I run it on a 24-core 4 cpu xeon it takes around 1.4ms to run. More interestingly on my machin...

How can I remap the keyboard with Perl on Win32?

I want to remap the keyboard with Perl on Win32 system. Is there any option to do that? If yes, could you provide an example? Remapping the keyboard means form example when the user presses a, he gets b or something else according to the remapping). ...

Calling CreateFile on a physical device path in a loop

I have some C# code that is calling CreateFile on a different physical device path each time through a loop(ie \.\PhysicalDrive1, then \.\PhysicalDrive2, ...) via pInvoke and then using the returned handle do some other low level windows stuff. At the end of the loop it calls CloseHandle on the handle. While debugging I noticed that th...