winapi

win32 c++ fstream wide argument

See link for what I'm talking about. I want to use point 1 in the link and #define tfopen _wfopen #define _T(s) L##s to do exactly what the link says is possible: std::ifstream file( tfopen("filename.txt", _T("r") ); But gcc (mingw) 4.4 says there's no matching call... Am I doing it wrong or is the info in the link above incorre...

Declaring a const BYTE * in c++

I am currently trying to make a call to this function call. Here's the declaration: const void* WINAPI CertCreateContext( __in DWORD dwContextType, __in DWORD dwEncodingType, __in const BYTE *pbEncoded, __in DWORD cbEncoded, __in DWORD dwFlags, __in_opt PCERT_CREATE_CONTEXT_PARA pCreatePara ); As ...

Is there a MAKELONGLONG function?

I need to combine two 32-bit values to create a 64-bit value. I'm looking for something analogous to MAKEWORD and MAKELONG. I can easily define my own macro or function, but if the API already provides one, I'd prefer to use that. ...

Event IDs don't match what is displayed in Event Viewer

In the System event log is an event with the following details: Source: Kernel-General Event ID: 1 Details: The system time has changed to ‎2010‎-‎07‎-‎17T02:58:20.285000000Z from ‎2010‎-‎07‎-‎17T02:58:20.285868600Z. The EVENTLOGRECORD also has a 1 for the EventID field, so it matches what we see in the Event Log viewer. So far so go...

Retrieve the entire rectangle of a scrollable window

I'm trying to retrieve the entire rectangle of a scrollable window using the WIN32 API. I thought that GetClientRect would return what I need, but that function appears to return only the current viewport. Is there a specific function call that returns the entire scrollable region as a RECT or must I call GetScrollRange to calculate th...

How can i attach userdata to each item in a listview? C++ Win32

I was thinking i could use the LVITEM structures LPARAM to attach a pointer to my class, but i can't seem to get it to work! Heres the main parts of my code: Creating the listview: hlvQuiz = CreateChild(WC_LISTVIEW, "", WS_CHILD | WS_VISIBLE | WS_VSCROLL | WS_HSCROLL | LVS_ICON | LVS_AUTOARRANGE, 0, 0, 320, 240, m_hwnd, FontN...

Get the handle to a process using its image name

Hello everyone, I need to obtain the Handle to a process using its Image Name so that I can use it with TerminateProcess function. Any help will be appreciated Farid ...

How can I check if there is a default printer (Windows)?

Is there a API or registry key which I can use from applications (native, Java or .Net) to check if the currently logged on user has configured a default printer? Update: Many thanks for the answers so far! According to the KB article http://support.microsoft.com/kb/156212, the registry entry (read/write) is only documented up to Window...

GetProcessName in C++

I have a function with blow detail. typedef part typedef DWORD (WINAPI *GETMODULEFILENAMEEX)(HANDLE hProcess, HMODULE hModule, LPTSTR lpBaseName,DWORD nSize); typedef BOOL (WINAPI *PFNTERMINATEPROCESS)(HANDLE hProcess,UINT uExitCode); /// GetProcessName function void GetProcessName(DWORD PID, PTSTR szProcessName, size_t c...

Take screenshot of desktop when Windows is locked (Win+L)

I want to take a screenshot of desktop while Windows is locked (with Win+L). Standard methods make a black screen, with code of pixel: COLORREF color = GetPixel(hdc, x, y); equal -1. Neither a user mode program nor a service could capture a useful image. Any ideas? ...

Get full running process list ( Visual C++ )

I am currently using the EnumProcesses function to obtain a list of running processes. Since my application runs in user space, however, it is not able to get handles for processes not running under the user, including System processes. Is there another method that will give me access to these? All I need are the process names. Thanks ...

correct usage of GetClipRgn?

I want to write a function that needs to set the clipping region on a DC but restore any existing clipping region on the DC when it is done. So I found GetClipRgn http://msdn.microsoft.com/en-us/library/dd144866(v=VS.85).aspx which sounds like exactly what I want but seems confusing. I couldn't find any examples of using it and Petzold...

Launch CALC.EXE and retrieve value using VB6

Hello all, EDIT Just to clarify, there is no intent of putting this into production. Purely from a coding/automatiion standpoint, and ignoring the fact that there are modules out there to do calcuations, how would one go about with the following request? I'm interested in how VB6 can use APIs to interact with other programs. END E...

How do you determine the optimal disk IO block size on Win32?

On Posix systems, the st_blksize member of the stat structure contains the optimal block size for IO for a given file. It looks like the Win32 implementations of stat (_stat & _stat64) do not support this field. What is the Win32 equivalent way of determining the optimal IO block size for a given file or filesystem? ...

How to get BS_DEFPUSHBUTTON to work?

My button has these styles: WS_CHILD | WS_VISIBLE | WS_TABSTOP | BS_DEFPUSHBUTTON it creates and lights up properly, but in my edit control, when i press ENTER, it does nothing! Heres the styles of my edit control: WS_CHILD | WS_VISIBLE | ES_AUTOHSCROLL | WS_TABSTOP I am not using a dialog, i have created my windows using CreateW...

C++\Win32 API - Load controls at run-time from xml

Is there a library that can load controls (buttons, text boxes, etc.) from an xml file? Kind of like in WPF. ...

[Win32] Lightweight file verification with PKI

I am trying to extend the legacy code of an online game to provide a reasonable assurance that the resource files associated with the game are the latest version, and not tampered with. I'd like to do this without DRM, without going into kernel mode, and without hardware assistance. What I ultimately settle on should ideally be about as ...

What API function do I need to use to know if a windows is beeing shown in the taskbar?

I am making a taskbar in C# and I know how to get a list of open windows, but I must know what windows I must show in the taskbar. How can I do this? ...

Get list of frequently used programs

Hi, I'm making an application that will collect some information on the user computer for statistical reasons, eg. What programs are installed, does it use wired\wireless connection, default browser, Does it use ms office, open office, other?, etc. I want to know what are the most used programs on the computer. I know windows keeps trac...

Blocking write locks with transacted NTFS

According to the MSDN documentation, transactional NTFS doesn't seem to allow one to block on opening a file for write - instead the open operation fails with ERROR_SHARING_VIOLATION. I'd like to block on writes instead - how can I do this? Ideally I'd like the following properties for the solution: Works over a network share (so no l...