FAQ Database Discussion Community


How To Get Window handles In Mozilla Firefox

winapi,mfc,ui-automation
How to get handles of all the child windows in Mozilla firefox. Spy++ is showing only one class and window caption for all the windows. I tried using GetWindow and FindWindowEx but got nothing. I want to read URL from mozilla firefox.

Calling a statically-linked static method in C++

c++,winapi,static-methods,static-linking
I'm trying to call a statically-linked static method of a C++ class, but I'm getting the VS linker error LNK2019, "unresolved external symbol". Here's the library source: // in header file #define DllExport __declspec (dllexport) class MyClass{ public: DllExport static HWND WINAPI myFunc(); }; // in cpp file DllExport HWND...

Named pipes and OVERLAPPED on Windows

winapi,named-pipes
I'm about to implement my first Windows service. The service will connect to a Bluetooth dongle, and liaison some commands and data to a single client process. Each process (client, server), shall have at least two thread - one blocking on Read(), another crunching business logic and doing an occasionally...

heap error after changing from new allocation to smartpointer

c++,winapi
extern "C" int __stdcall calcA( LPCSTR SerialNumber, double Diameter, int Design, int FoilSpacing, double RotorSpeed, double Altitude, double SupplyAirInletTemperature, double SupplyAirInletMoistureContent, double ExhaustAirInletTemperature, double ExhaustAirInletMoistureContent, double SupplyAirOutletFlow, double ExhaustAirInletFlow, double PressureDifference, bool PurgingSector, double* PowerTotal, double* PowerSensibel, double* TemperatureEfficiency, double* HumidityEfficiency, double* SupplyAirOutletTemperature, double*...

More convenient way to work with strings in winapi calls

string,winapi,rust
I'm looking for more convenient way to work with std::String in winapi calls in Rust. Using rust v 0.12.0-nigtly with winapi 0.1.22 and user32-sys 0.1.1 Now I'm using something like this: use winapi; use user32; pub fn get_window_title(handle: i32) -> String { let mut v: Vec<u16> = Vec::new(); v.reserve(255); let...

What does « program is not responding » mean?

windows,winapi,windows-process,not-responding
What does this message means, is there an API to « respond » to Microsoft Windows status queries ? I'm looking for a technical answer. Thanks :)...

Splitting TCHAR into bidimensional vector

c++,winapi
I wanna split a TCHAR message like the given example: TCHAR [1000] = "[X][X] [X][X][X] [X][P][-]..." into a bidimensional vector, to look like this: void Comunnication::receiveMessage(tstring msg){ TCHAR gameMessage[1000]; vector<vector<tstring>> gameMap; BOOL isSucceed = ReadFile(serverUpdatePipe, gameMessage, sizeof(gameMessage), &bytesRead, NULL); gameMessage[bytesRead / sizeof(TCHAR)] = '\0'; if (!isSucceed || !bytesRead){ break; }...

PostThreadMessage Fails to “Cleanly” Close Application

vb.net,winapi
I have been developing an application (VB.Net) which allows a user to open PDF files through Adobe Acrobat. These files are subject to change at any given moment so instead of opening directly from the server, I copy the file to the local drive and open that instead. Using a...

C++ and WinApi - usage of GetWindowText() to get parameters for C++ code

c++,winapi,file-io
I have coded some C++ console program which converts one filetype to another. I need to turn the console application into a window one. I have never made window applications. I have chosen WinApi, because I don't have much time and don't want to change IDE (DEV C++ 5.10), compiler/linker...

Win32 API logic error: Code compiles fine but the main window doesn't show up

c++,winapi
I'm rewriting a software I wrote, because of program size and performance problems; The code compiles fine but the window doesn't show up. I've looked into other questions about this but none solved my problem, that's why I'm asking a new question, for sake of completeness, please explain what is...

Is HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Cryptography\MachineGuid unique?

windows,winapi
This page says the following: In the Windows registry is a key called MachineGUID that has a UUID which is created by Windows during installation and should in theory be unique to the machine. In practice this is not the case and I have often come across duplicates of this...

How to get global Windows I/O statistics?

c++,windows,winapi
There is a WinAPI function GetProcessIoCounters that provides details of all I/O operations of a given process: number of read/write operations and number of bytes read/written since the process started. Most likely Task Manager uses this function to show these numbers: Is there a relatively easy way to get the...

How do I call LocalFree()?

c,winapi
I have this piece of code HLOCAL localHandle; char *lpText; localHandle = LocalAlloc(LMEM_MOVEABLE, 40); if(localHandle) { lpText = (char*)LocalLock(localHandle); //Call LocalFree(localHandle) or LocalFree(lpText) ???? } Should I call LocalFree(localHandle); or LocalFree(lpText); ?...

how to change Text to Speech voice and how to insert characters into char array

c++,arrays,windows,winapi,text-to-speech
I need to change the voie of the Text To Speech engine. when a menu is selected ID_SPEAK_PLAY I get the text of an edit box and simply read it. my situation can be solved in two ways : insert the XML code at the begining of ptrData without using...

Why do some WinAPI functions need sizes of structs passed as their parameters?

c,windows,winapi
For example, consider SendInput. The signature looks like this: UINT WINAPI SendInput( _In_ UINT nInputs, _In_ LPINPUT pInputs, _In_ int cbSize ); The documentation says: cbSize [in] Type: int The size, in bytes, of an INPUT structure. If cbSize is not the size of an INPUT structure, the function fails....

How can I send data between 2 applications using SendMessage?

delphi,winapi
I have 2 applications- Manager with this code: procedure TForm1.CopyData(var Msg: TWMCopyData); var sMsg: String; begin if IsIconic(Application.Handle) then Application.Restore; sMsg := PWideChar(Msg.CopyDataStruct.lpData); Caption := Caption+'#'+sMsg; Msg.Result := 123; end; procedure TForm1.Button1Click(Sender: TObject); const WM_MY_MESSAGE = WM_USER + 1; var h: HWND; begin Caption := 'X'; h := FindWindow('TForm1', 'Client');...

Sharing Folder API

c#,.net,winforms,winapi,shared-folders
I have C# WinForm application that needs to set sharing permission to some folder, and specify what users have access read/write/delete. I was wondering if there is any api or way to call something similar to when you right click on folder select Properties/Sharing/Advanced Sharing and window opens. If you...

Explain what problems could have this function (if any)

.net,vb.net,winapi,pinvoke,getlasterror
SCENARIO When P/Invoking, I thinked it could be a great idea to simplify/reduct tons of code by designing a generic function that calls the function, then it checks for the GetLastWin32Error I'm using this code: ''' <summary> ''' Invokes the specified encapsulated function, trying to provide a higher safety level...

Disable application taskbar icon's context menu in Windows 8.0 and 8.1

windows,winapi,visual-c++,contextmenu,windows-taskbar
In Windows 7, 8 and 8.1, when a user right-clicks on an application's taskbar icon, a context menu appears. Furthermore, a user can right-click on the application's name again (from the context menu) and another context menu appears, as shown in this image for Windows Explorer: Is there a possible...

User process can't see global shared memory created by service

c++,windows,security,winapi,memory-mapped-files
I have a Windows service (running in the system process) and a desktop application that need to share a configuration structure. The data originates in the app, but the user process doesn't have permission to create a global memory object so I create it when the service starts using CreateFileMapping()...

Confusion about CTRL_SHUTDOWN_EVENT handling in DLLs and WM_QUERYENDSESSION

c,winapi,console,shutdown
My UI is in a DLL. Right now, both the DLL and the EXE that uses it are compiled as console programs so I can use stdout and stderr for debugging and error reporting during development. One of the things is that I have an uninit() function that makes sure...

How do I free the standard icons and cursors (those loaded with LoadIcon/Cursor(NULL, IDI/IDC_WHATEVER))?

c,winapi
Another quick question this time: my DLL which handles UI stuff has an uninit() function that should be called before the program terminates that frees all resources (unregisters window classes, deletes a private heap, etc.). What is the required call for unloading IDI_APPLICATION, IDC_ARROW, and other system icons and cursors...

MoveFileEx() File removal on reboot

c++,windows,winapi
Currently I can remove a directory on reboot. Im currently doing this by using the MoveFileEx function along with passing the MOVEFILE_DELAY_UNTIL_REBOOTconstant. My question is if I have the following: Directory 1 and inside I have Directory 2... Directory 2 is unistalled which means the directory needs to be removed...

Dialog resource as a main form

c++,winapi
When using dialog resource as a main form for a Win32 Desktop application should one create a main form too or is creating a dialog and message handler for a dialog sufficient?

Why is _stprintf_s overwriting other variables but _stprintf is not?

c++,winapi,printf,malloc
I'm using visual studio for win32 programming class. I have a global array of string declared as TCHAR **bufTh allocated in memory like bufTh = (TCHAR**)malloc(nOfTh*sizeof(TCHAR*)); for (i = 0; i < nOfTh; i++) bufTh[i] = (TCHAR*)malloc(BUF_LEN*sizeof(TCHAR)); then I have some threads, each of them writing on a different string...

Passing HWND through to a method and storing in a class

c++,winapi
I am calling the following: // hMainWindow is a correctly functioning window handle app.GetMainWindowInfo().SetHndToWindow( hMainWindow ); Here are my classes: class App : public BaseClass { public: WindowInfo& GetMainWindowInfo(); void SetMainWindowInfo( unique_ptr<WindowInfo> windowInfo ); private: WindowInfo mainWindowInfo; }; class WindowInfo { public: HWND& GetHndToWindow() const; //void SetHndToWindow( HWND hndToWindow );...

How do I write a Windows 10 universal class library that references native code?

winapi,native-code,windows-universal
I have a C# class library that references and wraps Win32 native methods. But I can't seem to port this code over to a newer "universal" C# class library. What do I need to do in order to properly marshal these native methods?

Troubleshoot why PrintWindow is blank

winapi,screenshot
I am trying to capture screenshot of inactive window with PrintWindow. It works correctly for calculator and for capturing Google Chrome, but for some other applications, like games, it saves white area. What could be the reasons for PrintWindow to fail and how to validate them? EDIT: I want tool...

Is a StatusBar created in simple mode by default?

c,winapi
When a StatusBar is first created, for example: HWND hStatusBar = CreateWindowEx(0, STATUSCLASSNAME, "", WS_CHILD | WS_VISIBLE, 0, 0, 0, 0, hWnd, 0, GetModuleHandle(NULL), NULL); Is it created in simple mode or in multiple-part mode? or maybe this is not guaranteed and it is better to set the mode I...

Winapi AppendMenu LPCTSTR variable ampersand

c,winapi
I'm currently beginning learning WINAPI and have been following the tutorials on http://www.winprog.org On this specific tutorial, there is a section where the sub menu is created using AppendMenu. The final arg to this is a LPCTSTR, which as i understand would not really be interpreted by anything and is...

Why/how does winapi reverse the order of messages?

c++,multithreading,winapi
Consider the following code: CCritialSection listLock; std::list<CString> messageList; extern MyApp theApp; // public inheritance from CWinApp const int aMessageNumber = WM_APP + 123; void MyApp::EnqueueMessageForUIThread( const CString message ) { CSingleLock lock( &listLock, TRUE ); messageList.push_back( message ); theApp.m_pMainWnd->PostMessage( aMessageNumber ); } void MyApp:PopupMessageFromNonUIThread( void) { // This function is...

std::vector content change when read inside the main()

c++,string,winapi,vector
I was writing this function to search a file inside the computer but i encountered a problem: When I read the files that have been found during the search(using the for cycle inside the main() ) the directory are broken. With some debugging I saw that when pushed inside the...

Edit control doesn't generate WM_COMMAND messages

winapi,controls,editcontrol
I have an edit control. In the parent window I'm listening a WM_COMMAND message. But my control doesn't send it on change. Moreover, when I'm watching messages with Spy I can see only different keyboard messages on the edit control itself and the only message in the main parent window...

Does LoadLibrary return NULL or an error code < 32 on failure?

winapi
The MSDN documentation states If the function succeeds, the return value is a handle to the module. If the function fails, the return value is NULL. To get extended error information, call GetLastError. while Microsoft support has a list of return values less than 32 that indicate an error The...

Implementing callback function for dialog-based application

c++,c,visual-studio,user-interface,winapi
I was reading a very old tutorial on how to create a dialog-based GUI application in Visual C++ (source - in portuguese). Based on my weak knowledge on WinAPI programming I decided to modify the proposed code mainly to achieve two things: 1) Consistency with Unicode programming standard (using wWinMain...

What is the correct way to get a LOCALE_SSHORTDATE that is guaranteed to have a full (4-digit) year number?

c,winapi,locale
I want to create a date-time picker control that shows both date and time, as a combination of the DTS_SHORTDATECENTURYFORMAT and DTS_TIMEFORMAT styles. Since there is no such style built into the date-time picker, I have to do it myself with GetLocaleInfoEx(). I notice that by default, GetLocaleInfoEx(LOCALE_SSHORTDATE) seems to...

Populating a List Control with the sorted contents of an `std::multimap`?

c++,winapi,stl,mfc,clistctrl
As a follow-up to this question, I need a way to access my data by index. But the data needs to be sorted by timestamp, contain a filepath as a value, and be displayed in real-time as new elements are discovered. Considering that multiple files/folders could potentially contain an identical...

How should I read the filename in FILE_NOTIFY_INFORMATION struct

c++,winapi,filesystems,file-monitoring,readdirectorychangesw
I'm trying to monitor file changes but I am not really sure on how to read the filename in the FILE_NOTIFY_INFORMATION struct: HANDLE dwChangeHandles[2]; DWORD dwWaitStatus; wChangeHandles[0] = FindFirstChangeNotification(dirname.c_str(), FALSE, FILE_NOTIFY_CHANGE_LAST_WRITE); if (dwChangeHandles[0] == INVALID_HANDLE_VALUE) printerr(__FILE__,__LINE__,"FindFirstChangeNotification function failed.\n"); ... if ((dwChangeHandles[0] == NULL) || (dwChangeHandles[1] == NULL)) //final validation printerr(__FILE__,__LINE__,"Unexpected...

MASM console window creation troubles (maybe my stack frame??)

winapi,assembly,stack,x86-64,masm
I'm having trouble with the following code snippet. I'm compiling an asm file with a c++ file using visual studio express 2012. I've tried debugging calculating the addresses of the stack pointers and memory locations (still learning assembly obviously), but can't find a fault. (As I'm new it's probably something...

How to create a submenu for a popup menu?

c,winapi
When I want to create a popup menu, I would use the CreatePopupMenu() function. But what if one of the popup menu items needs to have a submenu, should I also use CreatePopupMenu() to create the submenu, or should I use CreateMenu()?...

New window opening with parent window's controls

c++,winapi
Sorry for english slaughter but i can't find anything about that. I'm trying to open an empty window in c++ with winapi but new window opening with parent window's controls like a clone. case VBTN: { vsa1 = CreateWindowEx(NULL, L"Window Class", L"Test", WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX, CW_USEDEFAULT, CW_USEDEFAULT, 350,...

Count digits in file using WinApi functions

c++,winapi,createfile
I need to count digits in file using CreateFile and ReadFile methods from <Windows.h>. Here's what I have: int CountDigitsInFile(PCTSTR path) { HANDLE hFile = CreateFile(path, GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); if (hFile == INVALID_HANDLE_VALUE) { _tprintf_s(TEXT("Open File Error")); return NULL; } TCHAR data[100]; DWORD dwRead; DWORD dwFileSize =...

is there a difference between running an executable and debugging it in Visual Studio?

c++,visual-studio-2010,winapi,runtime-error,visual-studio-debugging
I'm writing a piece of code in Windows which uses both winapi messagebox and some dynamic memory for RS232 application I saw a strange situation when the same application creates different error when I run it in debugging mode (using VS2010 and step-in debugging) and running it as an executable...

winapi: from HDC to an HBITMAP

c++,winapi,bitmap,gdi
I would like to do something which I believe is fairly simple but since I am new to the winapi I am finding a lot of problems. Basically I have an HDC (which I am BitBlitting from a loaded Bitmap) and I am drawing a rectangle on it. Then I...

SetWindowDisplayAffinity fails with error “Access denied”

java,winapi,jna
I am using jna.extra.User32Extra library in java to find a window and change the windowdisplayaffinity value. But it is returning "ACCESS DENIED" error code. HWND top= target.findWindow("WindowTitle"); System.err.println(User32Extra.INSTANCE.SetWindowDisplayAffinity(top, 0)); System.err.println(Native.getLastError()); The following code gives "false" and error code "5"(ACCESS DENIED). Do I need any extra permissions? What is the reason...

If statement not working in vb6

winapi,vb6
I want to make a program which could close a window with the title "Personalization" in vb6. The problem is that the if statement is not working.Here's my code(it only finds a window named "Personalization" without closing it): Option Explicit Private Sub Command1_Click() Timer1.Enabled = Not Timer1.Enabled End Sub Private...

Is Multi-layered SRWLock Valid?

c++,winapi
For Example, is this code valid? SRWLOCK srwLockA; SRWLOCK srwLockB; ::InitializeSRWLock( &srwLockA); ::InitializeSRWLock( &srwLockB); ::AcquireSRWLockExclusive( &srwLockA ); // First level /* do some stuff with member A*/ ::AcquireSRWLockExclusive( &srwLockB ); // Second level /* do some stuff with member A & B */ ::ReleaseSRWLockExclusive( &srwLockB ); // Second level /*...

Get list of process

delphi,winapi
I need to get the list of process with their PID. I know how to get the PID by its handle and viceversa, but the problem is that I'm not the one who create the process, so I don't have the handle nor the PID. I didn't find exactly information...

ICallFactory with 32-bit and 64-bit type libraries side by side

windows,winapi,com,registry,typelib
I have a in-proc COM server for which I want to build 32-bit and 64-bit versions. I can do this with no problem. However, I am encountering some issues when both versions are registered. I am not using ATL. In my DllRegisterServer function, I am using RegisterTypeLibForUser. I am acquiring...

Play a sound file in masm32 and to stop the other sound file at the same time [closed]

winapi,assembly,x86,masm32,playsound
So I am doing a game in assembly language and I am using the PlaySound() function to play a background song. I want to do that after I "die" in the game, another sound file will start playing a sound file, and at the same time will stop the other...

Does GetVolumeInformation() returns a unique volume serial number?

winapi
The documentation for GetVolumeInformation() says: This function returns the volume serial number that the operating system assigns when a hard disk is formatted. To programmatically obtain the hard disk's serial number that the manufacturer assigns, use the Windows Management Instrumentation (WMI) Win32_PhysicalMedia property SerialNumber. Does Windows assigns a unique volume...

Non blocking SHFileOperation

winapi
SHFileOperation needs a valid window handle in which it performs all window messages. I would like to use SHFileOperation independently from the current calling process, so I can close the process right after SHFileOperation has been called (and returned?!) which means I would like to "pass" it to another process...

How to handle an event message while using chrome embedded framework (CEF)?

c++,winapi,visual-c++,chromium-embedded
I'm using Chromium Embedded Framework(CEF) to develop a windows desktop application(using C++/Win32, No MFC). I have used the sample "cefsimple" project and extended on it till now. I have added "Handlers" for keyboard events etc. Everything works fine till now, I can get the handle of the browser window and...

C++ Windows API DlgDirList sometimes don't return the correct listing

c++,winapi,listbox,directory-listing,file-listing
I have 2 List Box, one always listing directories from a path and other listing the files from the selected directory. The first time i select a directory, the files are shown properly, but if i select another directory, it lists nothing. That's my current main.cpp, where all GUI stuff...

How to start an application as a child of a newly created explorer process?

c++,winapi,process
I'm working on an application that resembles a kiosk. After the application starts, it creates a new desktop with limited capabilities. Using a key combo I can move back and forth between desktops. In order to inform the user about the desktop it's currently using, or any other information I've...

C - Windows Exception Handler Invalid Handle

c,windows,winapi,exception,exception-handling
I have a problem about managing an exception. In my code I put hIn = INVALID_HANDLE_VALUE to test the exception, and "null" is a non existing file. My piece of code is __try { hIn = CreateFile (_T("null"), GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); hIn = INVALID_HANDLE_VALUE; ReadFile (hIn, buffer,...

MapViewOfFile() no longer works after process hits the 2GB limit

winapi,memory,out-of-memory
MapViewOfFile() works without any problem if our process has not hit the 2GB limit yet. However if the process hits the limit then MapViewOfFile() no longer works even if some or all of the memory is deallocated. GetLastError() returns 8, which means ERROR_NOT_ENOUGH_MEMORY, Not enough storage is available to process...

what to return or to do in a winapi window procedure in order to intercept an error and produce an error log entry

c,winapi
We have a c program. One policy in the development of this program is: "Every function/method that can fail should have a return value and should return the appropriate value in case of an error. No exception like behaviour." So, in the case of an error, our program produces a...

call Win32 API in flex to set Window Display Affinity

winapi,flex,air
I have created a Flex Desktop Application with Adobe Air. I need to protect the application from being captured. By changing the window display affinity of the application, the application can be protected from being captured. How to use win API in flex? Is there any other way to protect...

C++ Win32 how can i put this functions on separate cpp file?

c++,winapi
When this is in the main.cpp it works, but if i put in log.cpp gets LNK2019 error when i call log function with any number of arguments. string getDate() { SYSTEMTIME localTime; TCHAR strTime[128]; GetLocalTime(&localTime); wsprintf(strTime, "%04d_%02d_%02d_", localTime.wYear, localTime.wMonth, localTime.wDay); stringstream strm; strm << strTime; string date = strm.str(); return...

Obtain thread handles/id of a specific process

c++,multithreading,winapi
I have a multi-threaded embedded architecture that contains 6 application specific processes which are executed when the initialization process is executed. Likewise, each have their own number of threads that are running. What i want to do is suspend the running threads of 1 particular process based on whether the...

Is it valid to mutilayered a critical section?

c++,winapi,critical-section
For example, is this valid? CRITICAL_SECTION cs_A; CRITICAL_SECTION cs_b; ::InitializeCriticalSection( &cs_A ); ::InitializeCriticalSection( &cs_B ); ::EnterCriticalSection( &cs_A ); // First level /* do some stuff with A */ ::EnterCriticalSection( &cs_B ); // Second level /* do some stuff with A and B */ ::LeaveCriticalSection( &cs_B ); // Second level /*...

Access std::map from different threads

c++,windows,winapi
I have read that std::map is not thread safe. So if I am accessing (read/write) the std::map from different threads, should I simply wrap the relevant code in a critical section? Note: I am using Visual C++ 2010....

Is it possible to set a multiple conditions Breakpoint in Visual Studio 2013?

c++,winapi,visual-studio-2013
does anyone knows if its possible to set a multiple condition breakpoint on a specific line in Visual Studio 2013 (C++) ? I was trying using the '&&' but it didn't worked. I also couldn't find an answer on MSDN. the breakpoint that i wanna set is inside the WindowProc,...

How to build a dynamic array in C++ and return it back to C#/.NET

c#,c++,.net,arrays,winapi
I have to find the way to build the array of structs on C++ Win32 side. I don't have the initial number of items. It should be very fast to resize that array. When the list is build, I need to return it back to .NET. So That array(list) should...

c++ PE injecting additional functionality

c++,winapi
For example I have very simple C++ main function int main () { for (int i = 0; i < 10; i++) Sleep(10); return 0; } So this exe shuts down after 10 seconds from start. Now the question: Is there a way to JOIN(concatenate) two PE-applications? I am trying...

Using System::AnsiString class

c++,winapi
I am trying to import the code from the following answer: Get full running process list ( Visual C++ ) bool FindRunningProcess(AnsiString process) { /* Function takes in a string value for the process it is looking for like ST3Monitor.exe then loops through all of the processes that are currently...

Same version number for different Windows versions

c,winapi
In this page, there is something like this: Windows Server 2008 6.0 Windows Vista 6.0 GetVersionEx() returns the version number (i.e. 6.0), but as you can see, this number can map to two different Windows versions! So is there's a way to know exactly what Windows version I have?...

SetThreadExecutionState with ES_CONTINUOUS - what happens if app crashes before resetting flags

c++,winapi
I am going to use SetThreadExecutionState WinAPI function to keep system running during a certain job. SetThreadExecutionState(ES_CONTINUOUS | ES_SYSTEM_REQUIRED | ES_AWAYMODE_REQUIRED); According to MSDN, application must clear the flags set after the job is done if ES_CONTINUOUS is used. If my application crashed during the job, I would not be...

C++ Run-Time Library is set to /MT, but api-ms-win*.dll's are still missing

c++,multithreading,winapi
I'm using Visual Studio 2013 (v120_xp), and I'm programming using static libraries. "Run-Time Library" is set to /MT (multithreading), so I don't need extrenal .dll's. Today I added a function to display Windows 8 toast notifications from desktop app. Everything works fine, but when I'm testing the program on a...

Hide Window from taskbar without using WS_EX_TOOLWINDOW

c,winapi
I have a main Window and an About Window, The About Window is opened from the main Window, but the problem is that the About Window is shown in the taskbar! I have found that in order to hide a Window from the taskbar, I can use the WS_EX_TOOLWINDOW style,...

Error when I try EnumProcessModules in windows 8 64bit

delphi,winapi
I'm trying to pick up the modules of the process, according to msdn is not possible to handle the modules TH32CS_SNAPMODULE function in 32bit applications , using the EnumProcessModules function I can not list the modules of the defined process and go into an infinite loop. I just had success...

Windows Crypto API CryptEncrypt with the HashObject

c,node.js,winapi,cryptography,mscapi
I'm using Windows API CryptEncrypt with CALG_AES_256 I want to use a password to encrypt, from what I understand 1. CryptAcquireContext 2. CryptCreateHash (CALG_MD5) 3. CryptHashData 4. CryptDeriveKey 5. CryptEncrypt I need to decrypt with nodejs crypto & I used openssl enc to test nodejs decrypting was successful but with...

python Win32 Excel is cell a range

python,vba,winapi,range
I am writing a bit of Python code to automate the manipulation of Excel spreadsheets. The idea is to use spreadsheet templates to create daily reports. Saw this idea working several years ago using Perl. Anyway. Here are the simple rules: Sheets with the Workbook are process in the order...

Get all supported FPS values of a camera in Microsoft Media Foundation

c++,windows,winapi,ms-media-foundation
I want to get a list of all FPS values that my webcam supports. In How to Set the Video Capture Frame Rate msdn article it says that I can query the system for maximum and minimum supported FPS of a particular camera. It also says: The device might support...

How to execute a file with a different extension's associated application?

delphi,winapi,shellexecute,file-association
In my application, I would like to be able to execute a file with an arbitrary name and extension using the program associated with a different extension. For example, say I have a file called file.dat, but I wanted to open it with Notepad, as if it was named file.txt...

RegisterApplicationRestart with different path

winapi
I have two applications. Both of them use the same resources. Lets call these resources "profile resources". Application B cannot be started up until Application A shutsdown. So I have app A running and was trying to shut it down, then launch up with app B path. I explored RegisterApplicationRestart...

How do I declare OutputDebugStringA without windows.h macros?

c++,winapi
You know how Python has from urllib import *, but also offers from urllib import request, so you can just import that one symbol? Unfortunately C/C++ don't offer that but that's what I would like to do here: from windows.h import OutputDebugStringA, because all I need is that one function....

GetWindowsDirectory() API returns wrong (vba\vb6)

vba,winapi,vb6
on my Windows-Terminal user, I'm trying to have two application point to the same Windows directory, one written in VBA one in VB6. When calling the GetWindowsDirectory() API from VB6 it returns the correct path C:\documents and settings\%user%\Windows When calling it from VBA macro, it returns C:\Windows Notice that same...

Can a dialog intercept drag'n'drop messages passed to its controls?

winapi,mfc,drag-and-drop
If a dialog registers some of its controls as drop-targets, will drag'n'drop messages intended for those controls pass through the dialog's message processing in a way that the dialog can register a message handler to be notified/intercept those messages? In a similar fashion to this question, I want to catch...

Calling Win32 Functions From Julia

winapi,julia-lang
I would like to call File I/O functions (i.e. CreateFile, WriteFile etc) from julia using ccall. Do I have to indicate a library name as a parameter in ccall to call any function from win32 api? If yes, how can I determine the name of the corresponding dll?...

Generating a self-signed X509Certificate2 certificate with its private key

c#,.net,winapi,pki,x509certificate2
I'm not the most familiar with the unmanaged cryptography library in the Windows API, but alas I am trying to generate a self-signed X509Certificate2 certificate. Here is the complete code: using System; using System.Security; using System.Runtime.InteropServices; using System.Runtime.CompilerServices; using System.Security.Cryptography.X509Certificates; namespace Example { [StructLayout(LayoutKind.Sequential)] public struct SystemTime { public short...

Read lines from file async using WINAPI ReadFile

c++,multithreading,winapi,createfile,overlapped-io
I need to read several lines from file simultaneously, i.e. asynchronously. Lines in file are of the same size. For instance, I need to read the second and the fourth lines of file to separate variables or to an array. I'm more used to c#'s async/await and all these OVERLAPPED...

Win32 Message Pump and std::thread Used to Create OpenGL Context and Render

multithreading,winapi,opengl,c++11
If I have a function that does the following: bool foo::init() { [Code that creates window] std::thread run(std::bind(&foo::run, this)); while (GetMessage(&msg, NULL, 0, 0)) { TranslateMessage(&msg); DispatchMessage(&msg); } } Where run is defined as: void foo::run() { [Code that creates initial opengl context] [Code that recreates window based on new...

When and how often does the EV_RXCHAR event fire (from WaitCommEvent)?

c#,.net,winapi,events,serial-port
I've been digging through the reference sources for the .NET SerialPort and SerialStream classes, and have found that they fire their DataReceived events by waiting on WaitCommEvent(). The event usually fires just once, when the serial port has received some amount of data. Usually when the event fires, transmission has...

WTSEnumerateSessions from JNA

winapi,jna
I'm trying to start a UI application from a java based Windows Service. If figured out so far, that the only approach to make this work is to get a list of sessions, find the one thats currently active, get the user handle for that session and finally create a...

Specifying a Window Procedure for child Windows

c++,windows,winapi,wndproc,createwindowex
I would like to know if its possible to specify a WndProc for a Child Window created by CreateWindowEx. I have created a Window Class, the Main Window, the Window Procedure and a Message Loop already. The code works and I decided to keep it out for the clarity of...

How to run a dll as a service?

c++,c,winapi,dll,service
I know how to write a dll and how to write a service and how to run a dll with rundll32, but now I want to write a dll that install as a service in windows I don't know if that's possible or which function in dll should be exported?...

Restarting a process from another process

c++,winapi
I have two processes: ProcessA and ProcessB. When i launch my application, i call ProcessA which uses CreateProcess() to launch ProcessB. ProcessA is killed by ProcessB when my application receives command A. Likewise, ProcessB should relaunch ProcessA when it receives command B. Where i am stuck on is on the...

Click-through Controls in VB.NET

vb.net,winapi,controls,click-through
I need to create a picturebox on top of a textbox, that when clicked, passes the click onto the picturebox below the textbox. How would I go about doing this? Would I use SendMessage to, somehow, send the click down to the textbox and cancel it on the textbox? If...

MessageBox won't work when handling WM_DESTROY event from DialogBox

c,user-interface,winapi
While elaborating an answer for another question (by myself), I've come up with the idea of using a MessageBox to report the result of my dialog box. It is a WinAPI modal dialog box created with the DialogBox() function. However, I noticed that handling WM_DESTROY in the dialog's procedure function...

“Un-associate” socket from completion port

c++,sockets,winapi,winsock,iocp
CreateIoCompletionPort() is used to associate a socket with a completion port. However, when this socket is closed, then I need to "un-associate" it from the completion port. How can I do that?

Issues trying to display a configuration window for my screensaver (from a GUI app running with high mandatory integrity level)

c++,c,windows,winapi,windows-shell
I have an old project that comes with its own screensaver. The GUI application for the project has an option to "Configure screensaver" that should bring up my screensaver configuration window (that you would normally get from a Control Panel -> Display -> Personalization -> Screensaver -> Settings.) To display...

How can a dialog become responsive while waiting for a call to DoModal() to return?

winapi,com,mfc,modal-dialog
A button on a dialog causes a child dialog to be created, and displayed modally. e.g: void ParentDialog::OnButton() { ChildDialog dlg; int ret = dlg.DoModal(); } The parent dialog is initially unresponsive as expected. But, the child dialog also makes COM calls to a server module, which causes the server...

How to associate data to a ListView item?

c#,.net,listview,winapi
In Windows API, I can use the lParam memeber of the LVITEM structure to associate data to a ListView item. Can I do a similar thing in C#? Note: Of course I can just add an extra column to my ListView to do that, but I don't want to display...

If I created a process, does it mean that I will always be able to terminate it?

c++,c,windows,winapi,process
Say, if I created a process using CreateProcess or CreateProcessAsUser APIs, does it means that calling TerminateProcess(PROCESS_INFORMATION.hProcess) will always kill that process no matter what context my host process is running in (low privileged user, built-in Guest, etc)?

Accessing GetConsoleHistoryInfo() from managed code

c#,winapi,console-application,dllimport,managed
I've got a vaguely Java background and just installed Visual Studio Community 2015. Playing about with it so have a console app up and running and wanted to use above function after attaching to a different Console. Trouble is I have no idea about the appropriate declaration for this function...

Win32, MFC: Ending threads

c++,multithreading,winapi,mfc
I have a DLL which has a CWinThread based class called CWork. I create it using AfxBeginThread. In this class I defined a procedure that will loop infinetly and perform a certain task. This procedure will be used as a thread by itself. I create it also using AfxBeginThread. Now,...

Issue finding exe path of all windows in python

python,windows,winapi
I am using the code below to determine the foreground window and find the path for the .exe file that created it. hwnd = win32gui.GetForegroundWindow() _, pid = win32process.GetWindowThreadProcessId(hwnd) hndl = win32api.OpenProcess(win32con.PROCESS_QUERY_INFORMATION | win32con.PROCESS_VM_READ, 0, pid) path = win32process.GetModuleFileNameEx(hndl, 0) print path This workd for windows such as Google Chrome,...

physical screen size acquired by GetDeviceCaps is not the actual physical size of my screen

c++,winapi
Under Windows 7, I use the following code to get the physical width in mm of screen. The 'hSize' is 482 which is much larger than the actual size which is about 310 (measured with ruler). Why is that? HDC screen = GetDC(NULL); int hSize=GetDeviceCaps(screen,HORZSIZE); PS: I need DPI value...