Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Get info on a running app?

Status
Not open for further replies.

RebeccaLynn

Programmer
Nov 17, 2003
250
US
I want to select a running app (maybe by dropping an icon on it, or clicking on it. and then get info from it to use in my app (mainly the startfile name of that app.) can anyone help?

Becca

Somtimes, the easy answer is the hardest to find. :)

Still under construction ...
 
Could you explain what you want to in a little more detail.

It sounds like you want to have an application that can pull information from running processes or applications? You are asking about finding the startfile name, but how are you going to know what app to get information from if you don't know the name of it?

 
I have seen a program that lets you drop an icon onto a running application. it then gets the start file and path from that application. That is what I am trying to figure out how to do in VB.net.


Becca

Somtimes, the easy answer is the hardest to find. :)

Still under construction ...
 
ah I see,

I would think the easiest way to do that would be to find out how to tie into windows default right click event. You could add an entry to the drop down for your application. If you can do that, your drop down could have all the information about what ever application you right clicked on.

I have never tried to do something like that so someone else might have a better idea, but that is what I would try.
 
This goes back to the previous question you asked. I forgot about that one. I'm not sure either. I thought at first you wanted to drag and drop between apps. But this might require API calls. Check out You might want to ask the same question in the VB 6 forum as well.
 
Position := Img_Dropper.ClientToScreen(RelPosition);
WindowHandle := WindowFromPoint(Position);
Modulename := WHandleToFileName(WindowHandle);
Function WHandleToFileName(WindowHandle: hWnd): String;
Var
ProcessID, NumberReturned: DWORD;
ProcessEntry: TProcessEntry32;
hSnapShot: THandle;
Cursor: Boolean;
ProcessHandle: THandle;
ModuleHandle: HMODULE;
RC: Boolean;
ReturnName: Array[0..2048] of char;
Begin
Result := '';
GetWindowThreadProcessId(WindowHandle, @ProcessID);
// Do this based on windows version
if (WinPlatform = 'NT') {AND (WinVersion<5)} then
Begin
ProcessHandle := OpenProcess(PROCESS_QUERY_INFORMATION or PROCESS_VM_READ, FALSE, ProcessID);
RC := EnumProcessModules(ProcessHandle, ModuleHandle, 4, NumberReturned);
if RC then
Begin
GetModuleFilenameEx(ProcessHandle, ModuleHandle, ReturnName, 2048);
Result := ReturnName;
End;
End
Else
Begin
hSnapShot := CreateToolHelp32Snapshot(TH32CS_SNAPPROCESS, ProcessID);
ProcessEntry.dwSize := SizeOf(ProcessEntry);
Cursor := Process32First(hSnapShot, ProcessEntry);
while (Cursor) do
Begin
if (ProcessEntry.th32ProcessID = ProcessID) then
Begin
Result := ProcessEntry.szExeFile;
break;
End;
Cursor := Process32Next(hSnapShot, ProcessEntry);
End;
CloseHandle(hSnapShot);
End;
End;


Becca

Somtimes, the easy answer is the hardest to find. :)

Still under construction ...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top