winapi

copying and pasting from/to clipboard with python/win32

I downloaded the win32 for python 2.6 from this site. This is the code to get/set the clipboard. def test(): OpenClipboard() d=GetClipboardData(win32con.CF_TEXT) # get clipboard data SetClipboardData(win32con.CF_TEXT, "Hello") # set clipboard data CloseClipboard() if __name__ == '__main__': if sys.platform == 'wi...

How can we check if a file Exists or not using Win32 program?

How can we check if a file Exists or not using a Win32 program? I am working for a Windows Mobile App. ...

WinAPI: Call context menu entry provided by shell extension

The software Dropbox provides an shell extension which adds context menu items to all files in a specific folder. One of these generates a public link to view the selected file. In a C# tool I want to call this entry without any user interaction. I want to achieve the same behavior as if the user clicked on the context menu item of a se...

How can I change Menu's Text color?

I want to change Menu's Text color, but not MenuItem. ...

Change programmatically both keyboard layout and language

With ActivateKeyboardLayout I am able to change keyboard language to some of the layouts given by GetKeyboardLayoutList. There is one problem though, I can't choose the actual keyboard, only the language. The keyboard I get is simply what the user chose previously for that language. So if I have English US (HKL=0x04090409) and US Dvorak ...

How to find if parent of USB device is a hub

I need to find out if parent of USB device is a hub or host. Current plan is to use CM_Get_Parent() to get the DEVINST and use SetupDiGetDeviceInfoListDetail() to get the SP_DEVINFO_LIST_DETAIL_DATA structure, but from there I am looking for information to parse against to will tell me if the parent is a hub. Any pointers/hints/advice w...

Creating an IShellItem instance for a non-existent file

How can I get an IShellItem object for a non-existent file (or directory)? SHCreateItemFromParsingName and SHCreateItemFromRelativeName fail with 0x80070002 (file not found) and ILCreateFromPath returns a NULL pidl. First I thought it might be impossible, but for example IFileSaveDialog creates such an IShellItem for its result (if ...

winapi threads take time to initialise before message passing works?

I have a main program that creates the threads in order: ThreadB then ThreadA (which is passed ThreadB's ID) using the CreateThread function. Thread A sends a message to Thread B using PostThreadMessage. B gets the message using GetMessage. The problem I am having is that PostThreadMessage blocks randomly the first time it is called an...

Why does my ReadFile call fail if it is not called within the same function as CreatePipe?

I'm having trouble using pipes in a larger application and so I created a minimal test application to investigate the problem. I'm creating a pipe: Dim sa As SECURITY_ATTRIBUTES Dim R As Long sa.nLength = Len(sa) sa.bInheritHandle = 1 R = CreatePipe(hRead, hWrite, sa, 0) //hRead declared globally Debug.Print "CreatePipe: " & R and t...

Why call CoFreeUnusedLibraries() before OleUninitialize()?

While trying to resolve process hanging on CoUninitialize() I came upon a piece of code shared by many of our projects. When a program is going to quit it first calls CoFreeUnusedLibraries(), then immediately OleUninitialize(). While the effect of OleUninitialize() is quite clear I can't find why one would want to call CoFreeUnusedLibra...

EnumPrinters() + error RPC_S_SERVER_UNAVAILABLE (1722)

Hi, I am working on a sample to get the list of printer connected to machine. For that I am using EnumPrinters() API to get the printers. Randomly it gives the error RPC_S_SERVER_UNAVAILABLE (1722). I tried to search in the net, but I could not get the solution. Please help me to fix this issue. ...

What's the correct way to get a gradient in a toolbar in win32 API (no MFC)?

For example, Notepad++ has a toolbar that looks like this: http://yfrog.com/58npptbp 7-Zip has a toolbar that looks like this: (stack overflow won't let me post more links because I'm new) Whereas mine is boring and flat, like this: (stack overflow won't let me post more links because I'm new) How do I do make my toolbar 3d? Is the...

How to make a C++ EXE larger (artificially)

I want to make a dummy Win32 EXE file that is much larger than it should be. So by default a boiler plate Win32 EXE file is 80 KB. I want a 5 MB one for testing some other utilities. The first idea is to add a resource, but as it turns out embedded resources are not the same as 5 MB of code when it comes to memory allocation. I am think...

Keyboard repeat count

Hello i am having trouble utilising the repeat count parameter of the msg WM_KEYDOWN ... using visual c++ 2008 for some reason or the other the repeat count of the msg does not increment if the key is held for long.... for eg if i use this code:: ---------- *TextOut(hdc,cxChar*2*(sizeof(szBuffer)/sizeof(TCHAR)),i*cyChar,szBuffer,wspri...

How to get correct hDevMode values from CPrintDialogEx (PrintDlgEx)?

I'm displaying a CPrintDialogEx dialog to choose a printer and modify the settings. I set the hDevNames member so that a default printer will be selected, but I leave hDevMode set to NULL. On successful return I pull some values such as paper size out of the returned DEVMODE structure from hDevMode. I'm having a problem because hDevMode...

Finding the Child Window inside a Microsoft RemoteApp Programmatically

Background I'm using SendKeys() to send keyboard commands to the active window, but I'm not having any luck finding the child window when the application is running through RemoteApp. It all works as expected when I run the application locally. Microsoft RemoteApp allows users to connect to applications through the RDP protocol, but i...

How to disable output buffering in Process.StandardOutput

This question has been asked more than once before, but I have not found a satisfactory answer in any of those discussions. I am launching a command-line process that produces a real-time measurement to STDOUT, producing a new result approximately every second. Using System.Diagnostics.Process.StandardOutput results in completely unacc...

C++ - Window Message loop is freezing

I have this class here that I made based on another one I had. It is supposed to handle the whole creating windows and stuff, but it seems to be getting into a hang now. The older version used to work fine, I don't know WHAT I may have forgotten to add to this one that might be causing it to hang like this. This is the message loop: ...

Is RegNotifyChangeKeyValue as coarse as it seems?

I've been using ReadDirectoryChangesW to monitor a particular portion of the file system. It rather nicely provides a partial pathname to the file or directory which changed along with a clue about the nature of the change. This may have spoiled me. I also need to monitor a particular portion of the registry, but it looks as if RegNotif...

OpenGL Glass HUD?

Hello I Would like to know how to make somthing that looks like "Glass" the example would be in the game called Pikmin. its in the HUD and i would like to know how to create somthing similar. I Am not trying to copy the game i just like how it looks. It looks like this: http://3.bp.blogspot.com/_CWor6UdXxBk/SbaZDWSF6VI/AAAAAAAAFCU/UQgB...