winapi

How to detect OS of Win7 Home Premium, Win7 Professional, Win7 Enterprise or Win7 ultimate?

How to detect OS of Win7 Home Premium, Win7 Professional, Win7 Enterprise or Win7 ultimate? ...

CreateDC fails with error code 0

I'm printing using CreateDC, passing in a valid DEVMODE structure and getting NULL returned which indicates an error but GetLastError returns 0. m_hDC = ::CreateDC(L"WINSPOOL", PrinterName, NULL, pDevMode); if (m_hDC == NULL) { throw Exception(GetLastError(), __LINE__, _T(__FILE__)); } This is working for all of my customers apart f...

GetExitCodeProcess process termination status codes?

Does anybody know where can I find a list of GetExitCodeProcess' process termination status codes? I've done some search in the internet and haven't been able to find one. I'm receiving a 33102 code from a GetExitCodeProcess call and I don't understand why. I hope getting a description for this error code will help me sorting this out. ...

'Safe' DLL Injection

Not a terribly good question, sorry. I have a program that needs to be alerted when a file is opened from explorer (i.e. ShellExecute(A/W) is called). Unfortunately, Microsoft removed the COM interface (IShellExecuteHook) that allows you to hook these events in Vista and up, supposedly because older code could cause a crash due to chan...

Why Win32 HeapReAlloc() changes values?

Hi there! I'm writing an app in C using win32 API. When I try to enlarge the size of my array, using the HeapRealloc() function, it changes my current values in the array, instead of copying them. The code I use to reallocate memory: BOOL ChangeFeedArraySize(UINT newSize) { char tempChar[20] = ""; PFEED tempArr; if (newSi...

Error on getting AVI file duration

I am using VFW unit from JEDI wrapper on WinAPI. The code I am writing is intended to search user drives and detect warez. We do MP3, WMA and some graphic file search. Now we want to detect illegal movies. I want to open AVI file, read some details from it and close it. I have the following code: uses WFV; //from JEDI api wrappers pro...

How to obtain the PIDL of an IShellFolder

If I have an IShellFolder interface pointer, how might I obtain its PIDL? I can see how to enumerate its children, and I can see how to use it to compare any two children... but how might I get its own pidl? I ask because I'd like to know "Is this IShellFolder == Another IShellFolder". I can use IShellFolder::CompareIDs() - but I have...

Scancode when I press a key is different. Is Microsoft specification wrong?

I am using Windows XP pro SP3. Standard english keyboard. I live in the USA; never touched the keyboard settings. Stock install. So, when I press check the scancodes my program is returning they are as follows: A = 30 S = 31 D = 32 F = 33 G = 34 When I check the microsoft specification (page 11 of the document:: http://download.micr...

How to use a dll?

I have a .dll file and the .lib file for it. The DLL talks to an electronic key reader, and allows you to read/write the key ID. This is the only documentation that comes with: DLL Usage: boolean = object.DevicePresent (PROPERTY: true if the device is present) boolean = object.KeyPresent (PROPERTY: true if a key is in the device) long...

Cross platform unicode path handling

I'm using boost::filesystem for cross-platform path manipulation, but this breaks down when calls need to be made down into interfaces I don't control that won't accept UTF-8. For example when using the Windows API, I need to convert to UTF-16, and then call the wide-string version of whatever function I was about to call, and then conve...

How does a program look in memory?

How is a program (e.g. C or C++) arranged in computer memory? I kind of know a little about segments, variables etc, but basically I have no solid understanding of the entire structure. Since the in-memory structure may differ, let's assume a C++ console application on Windows. Some pointers to what I'm after specifically: Outline of...

Getting AVI file duration

I am using VFW unit from JEDI wrapper on WinAPI. The code I am writing is intended to search user drives and detect warez (note: deciding if some file is legal or not is beyond scope of this question). We do MP3, WMA and some graphic file search. Now we want to detect illegal movies. I want to open AVI file, read some details from it an...

Can address space be recycled for multiple calls to MapViewOfFileEx without chance of failure?

Consider a complex, memory hungry, multi threaded application running within a 32bit address space on windows XP. Certain operations require n large buffers of fixed size, where only one buffer needs to be accessed at a time. The application uses a pattern where some address space the size of one buffer is reserved early and is used to...

How do I control the text input panel programmatically (tabtip.exe) in windows vista/7.

Hi, I'm adapting an application for touch screen interface and we're want to use the tablet text input panel included in windows vista/7, specifically its keyboard. I want to show and hide it as appropriate for my app. Basically I want ShowKeyboad() and HideKeyboard() functions. What's the best way to control this. I looked at the ITex...

Howto Track down variable Corruption

I have a MFC class derived from CStdioFile declared as follows // Datafile.h class CDataFile : public CStdioFile { public: CDataFile(void); ~CDataFile(void); int OpenFile(LPCWSTR FileName); } After my OpenFile function is called the FileName variable is being corrupted. int CDataFile::OpenFile(LPCWSTR FileName) { m_OpenFl...

Overwriting an Open File in Windows

In what situations does Windows allow you to overwrite an open file? Is that ever allowed? This includes renaming a different file to the same name as an open file. ...

Checking a Win32 Tree View Item Automatically Checks all Child Items

I am using the Win32 API and MS Visual C++ 6 to build a tree view of a directory structure, with check boxes associated with each tree view item. My goal is to be able to check a parent folder, and have that automatically check all of its associated children. However, after digging through MSDN, I have not been able to find a control...

How can we find the process ID of a running Windows Service?

I'm looking for a good way to find the process ID of a particular Windows Service. In particular, I need to find the pid of the default "WebClient" service that ships with Windows. It's hosted as a "local service" within a svchost.exe process. I see that when I use netstat to see what processes are using what ports it lists [WebClient] ...

Parse information from programs added to taskbar with C++

Basically what I am trying to do is write my own pseudo task bar in C++. The program needs to idle until another program is started up, at which point it needs to visually depict that the other program is running. For each other program that is running, the user should be able to click on the visual representation and have Windows switch...

Persist a pidl (ITEMIDLIST)

I'd like to persist pidls between sessions, so that my application can remember the users' folder selections, wherever they may be in the namespace, even if they're not file-system folders. I have a feeling that the way to do this is to write out the binary contents of the ITEMIDLIST itself, but I can't confirm this for sure, since thes...