Im using C++ and im trying to create a program similar to handle.exe from sysinternals.
Basically, i am getting the filename from the user, and I need to be able to display which process is locking the file.
Does anyone know where I can get this information from? I've tried using some process functions in winapi, but I cant figure out how to get this information,
Here is an example of what im trying to create:
http://www.kartmann.org/freeware/WhoSLocking/ReadMe.htm
Thanks in advance
There is an undocumented option on NtQuerySystemInformation to get the file handles for a process. There is sample code here.
Second sample (in Delphi) is here.
Related
I'm not sure if anyone asked this, I tried to find it but I couldn't. I'm starting a new project and I want to make a GUI in C++ that will run another application called "GAMS" which does some optimization problems for me.
Now, I do know how to create GUI and how to run GAMS itself using ShellExecute(), but I don't know how to run those algorithms from my GUI.
All I need is to run scrip that I wrote in GAMS and that I would be able to manipulate with data that I receive from GAMS.
So my question is, can I send commands from my GUI to GAMS?
Thanks in advance!!
Im trying to write some code to list out any file handles with an associated process. I understand tools like handle and processexplorer exist. But these dont work for the implementation of the code im writing since it needs to be internal to the code. Sadly i cant seem to find what api calls procexe uses to find the file handles associated with that PID. Any one know good sources i can check out to figure this out?
I have prepared a program launcher in C++ (the only language I know), which accepts strings as program trigger.
But however hard I try I'm unable to give it a GUI like look; using graphics.h's graph functions creates graphics but in cmd like window.
All I need is a small widget/window like thing that sits on the desktop where a user can type the command string (and error messages can be displayed as usual).
Can I get a code snippet for such a widget/window?
The input string may be copied to a .txt file and my prog will read it from there.
P.S.- I'm a beginner & rookie so please avoid complex alternatives.
Well, one of the easiest options in my opinion is to use .NET Framework:
http://10rem.net/blog/2010/03/04/my-first-windows-cplusplus-application-in-ages-hello-world-in-win32-with-visual-cplusplus-2010
http://msdn.microsoft.com/en-us/library/bb384845.aspx
I wish to use the functions of autohotkey within a C++ program.
I am currently running my scripts triggered by the c++ program- I just run them as a .bat file. This works well but the problem is that I cannot return values from the script to the c++ program.
I wish to be able to read the position of the mouse from the script and make decisions based upon this in my C++ program. My scripts do quite complex things- so doing this in autohotkey is the best solution for me- I have knowledge of C, but little of C++.
I have read about the Autohotkey .DLL - I know how to trigger it but not how to read values from it. If anyone could instruct me or even post example code of a .dll being loaded and a value sent to a script and a value returned- I would be eternally grateful!!
I have spent hours on this and to no avail!
to return a value, could this possibly work http://www.autohotkey.net/~tinku99/ahkdll/functions/ahkgetvar.htm
I'm not sure about the dll, but you could just write your own application in Autohotkey and package it along with your C++.
The communication takes place over a hidden window with an edit control and a button. You use one application to set text in the edit box, and then to click the submit button. The other application owns the window can process whatever is put into the edit control - as if you were passing a variable. Basically, that's it.
Check out this thread where I've explained it in more detail: How to send a command to a running application via commandline
Now, that's not quite what you wanted, but the effect is the same, and you already know all the api.
I'm in the process of learning C++. I've created a boilerplate Win32 app within VC++ 2008. I've studied through the code and am ready do do a bit of experimenting. I thought it would be cool to print all the windows messages received in the message loop to the form created via the boilerplate code. I for the life of me, can't figure out the method of getting text onto that form. I can't seem to identify and named object that I can use to reference that damn form. The best I can figure is I need to use the handle to reference the form somehow. Still, even if I did know how to reference the form, I'm not sure I know how I would create a label to display the text. Anyway, if someone could just point out what methodology I need to learn to make this happen it would be much appreciated.
Thanks,
Donovan
If you've created a label using resources, use its resource ID and
HWND *pWnd = ::GetDlgItem(mainDialogHwnd, IDC_YOUR_RESOURCE_ID);
::SetWindowText(pWnd, "Your Updated Text");
There are MFC equivalents for those too, should get you in the right direction. Note that posting message loop means lots and lots of information... might not want to do that. Check Spy++ if that's still available and in use today to see how many messages an app gets!