winapi

Does a "pure" IDispatch interface require a proxy/stub DLL?

..for an out-of-process-server, or can I call a dispatch interface without registering a proxy/stub? The interface in question is very high level, so performance is a non-issue, and I could make the whole thing registration-free, which is a big plus ...

How to convert Win32 HRESULT to int return value?

I'm writing a Windows console application in C++ and would like to return zero on success and a meaningful error code on failure (i.e., S_OK should return 0, and E_OUTOFMEMORY should return a different return value than E_FAIL and so on). Is the following an okay approach?: int wmain(int argc, wchar_t *argv[]) { HRESULT hr = DoSomet...

Win32 API CopyFile() fails to send multiple files

While attempting to use the CopyFile() function I have encountered a strange error. It will write neither of the files to my destination. Here is the code. The section when I send files has been commented. Keep in mind this code is a rough draft so ignore the function definitions. /* BrowserFind.c Version 0.2 07/29/09 LogicKills ...

Implementing condition variables for CRITICAL_SECTIONs for Winthreads for XP

I have a desire for POSIX style condition variables on Win32. I have some code that needs to run on XP, so I can't use Vista/Server 2008's CONDITION_VARIABLE. It makes use a of a pseudo condition variable class currently, which is based on leaving the critical section and signaling an auto reset event for signaling / waking. For waitin...

Counting the total of same running processes in C++

Hello there, I'm looking for a way to detect the # of running processes that has same process name. In example, I ran notepad three times. notepad.exe notepad.exe notepad.exe So it will return 3. I currently have these code to detect a running process, but not counting its running process quantity. #include <iostream> #include <win...

Win32API - How to get file name of process from process handle?

How can I get the file name of process from a process handle? I'm using Win32 C++ (Visual C++ Express Edition). Thanks. ...

How can you read values from an open application in Windows?

I want to create a program or use a program that will read the memory values out of another application. Does anyone know of an application/library that will do this? The target app is this. I would like to read the exchange rate values from it. I'm an experienced c# programmer, but have never worked with the Win32/user32 api ...

How do I send key strokes to a window without having to activate it using Windows API?

    I have made an application already that sends commands to an activated window. I want to be able to use the computer while my process is running because as soon as I switch focus to another window the key strokes being sent via send keys will go to the window I just switched to.     Currently I use FindWindow, IsIconic, and ShowWin...

How can I convert an offset in text segment of an Win32 executable into a pointer at runtime?

How can I convert an offset in text segment of an Win32 executable into a pointer at runtime? When using a disassembler, I can see the relative addresses. But how can I convert them to an absolute address at runtime? For example: .text:402BE620 Which address is that at runtime? How can I convert that number into a pointer? Some bac...

Switch Focus between Cmd windows, Force focus (keep 1 instant of program running)

hello, i am creating a simple windows cmd program, and i am trying to make sure it only runs once (if u double click the exe file, only one instance will show.. so in my code.. i added a named mutex(the name is a GUID) .. if a 2nd instance of the program was started, it would show the message telling you, that you already got an instanc...

winapi c - read/write mbr of system drive

Does anyone have any example code that shows how to identify the system boot harddisk, and read/write the mbr from the harddisk in windows xp and vista? I know createfile can be used. But I do not know how to properly identify which device is the boot device. Like how do you find out which ones you are meant to use? \.\Volume{GUID}\...

Gadget development

Hi! I'm searching about gadget development when I found this site. I'd like know if somebody know how get open windows name? I want get a collection of all the open windows. I know in VB.NET, but dont know in DHTML/VBScript for Windows Vista Sidebar. If somebody can help me, I'll to stay grateful! Thanks Erik ...

Is setting parent for a window from different process correct?

I have two applications having two different top level windows: App1 -- Window1 App2 -- Window2 Now, I am creating a Dialog Dlg1 in App1 and I want to set window2(App2) as a parent window. ( That is because I want my Dlg1 to come on top of Window2 ). I created the dialog by setting Window2 as parent. It worked. But is it the correct ...

Thread-local singletons

I would like to create a singleton class that is instantiated once in each thread where it is used. I would like to store the instance pointers in TLS slots. I have come up with the following solution but I am not sure whether there are any special considerations with multithreaded access to the singelton factory when thread local storag...

Drawing transparent/alpha images using CxImage

I am trying to draw a transparent (alpha) PNG image using CxImage, but it seems I'm missing some obvious step... The code so far is: CxImage image(m_pImage, m_lSize, CXIMAGE_FORMAT_UNKNOWN); CRect rcOut = rc; rcOut.left = (rc.Width()/2) - (image.GetWidth()/2); rcOut.right = rcOut.left + image.GetWidth(); rcOut.top = (rc.Height()/2) - (...

How to call the RJ45 as a serial port for interfacing?

Hi, I'm currently working on a serial interfacing project based upon connecting to the rs232 port. However, seeing as a decent number of laptops and/or PC's seem like they might have their rs232 ports disappear within the next 5 years, I was considering using the RJ45 modular port for my project (EIA/TIA 568). However, I'm not quite sur...

Which is faster: SetEvent, SendMessage, PostMessage

Environment: Win32, C/C++ All three (3) can be used for a thread to signal to main() that it has completed an operation for example. But which one is the fastest signal of all? hmm... ...

Send windows message to a Windows Service

Is there any tool to send (mimic) a windows message like 'WM_ENDSESSION' to a windows service? OR How can I send a windows message to a process using C#? (I know only C#) EDIT: Purpose: Basically I have to debug a windows service for fixing a bug that occurs only on system shut down. ...

How to get a Win32 Thread to wait on a work queue and a socket?

I need a client networking thread to be able to respond both to new messages to be transmitted, and the receipt of new data on the network. I wish to avoid this thread performing a polling loop, but rather to process only as needed. The scenario is as follows: A client application needs to communicate to a server via a protocol that is...

Scrollbar flicker

I have a problem with the way my scrollbars are drawn. Because of external limitations (my application being a plugin running in an external window that insists on painting over any regular child window), I have to use SCROLLBAR-class windows (as opposed to using WS_CHILD | WS_VSCROLL) For almost every message received, the scrollbar is...