[Solved] How can I manage windows of applications opened using Win32 API (Notepad, Word, Outlook, Chrome etc.)

The answer is you cannot replace the window procedure cross-process with SetWindowLongPtr and SetClassLongPtr . Calling SetWindowLongPtr with the GWLP_WNDPROC index creates a subclass of the window class used to create the window. An application can subclass a system class, but should not subclass a window class created by another process. Calling SetClassLongPtr with the … Read more

[Solved] Is there anyway i can detect “~” by using GetAsyncKeyState?

The virtual key code of “~” is VK_OEM_3. More virtual key codes can be referenced: https://docs.microsoft.com/en-us/windows/desktop/inputdev/virtual-key-codes How to use it, please refer to MSDN A simple example: #include <Windows.h> #include <iostream> using namespace std; int main() { BOOL OEM_3 = FALSE; while (1) { if (GetAsyncKeyState(VK_OEM_3) < 0 && OEM_3 == false) { //Press down … Read more

[Solved] deleting file in ntfs using c

The call to DeleteFile() does work and in your case it did work. DeleteFile() is contracted to delete the file you specify, if it can be deleted. If the file could be deleted, then it will be. If the file could not be deleted then it will not be. If DeleteFile() returns false, what the … Read more

[Solved] How to elevate privileges for child process

OK, this shouldn’t actually be too hard, provided that UAC is configured with the default settings. I believe that the reason CreateProcessWithLogonW() is failing is that the target executable requires elevation. If you instead run an executable that is not configured to require elevation, it should work. At that point, you are running in the … Read more

[Solved] Battery Status in winforms

I thing that what you want to do is this: private void BatteryStatus() { System.Management.ManagementClass wmi = new System.Management.ManagementClass(“Win32_Battery”); var allBatteries = wmi.GetInstances(); foreach (var battery in allBatteries) { int estimatedChargeRemaining = Convert.ToInt32(battery[“EstimatedChargeRemaining”]); label13.Text = “Remaining:” + ” ” + estimatedChargeRemaining + ” ” + “%”; } } No need for and if statment, the … Read more

[Solved] c++ breaks on class function

EDIT: Wait… I hadn’t realized that this function is a member of the CXFileEntity class. It doesn’t look like it’s a static method, either. So in order to call this function, you already need to have instantiated a CXFileEntity object! Therefore, it’s likely that you absolutely do not want to be either deleting or creating … Read more

[Solved] returning a buffer in c [closed]

Is it even possible for “main” to return a buffer? No and you shouldn’t. What should main() return in C and C++? How should I create, append string and return it? char aString[FIXED_SIZE]; memset(aString, 0, sizeof aString); strcpy(aString, “This is a string”); solved returning a buffer in c [closed]