First SetCapture (); Capture program outside of the mouse click,
Then in the
LRESULT CDragListCtrlDemoDlg: : WindowProc (UINT message, WPARAM WPARAM, LPARAM LPARAM)
{
Case WM_LBUTTONDOWN:
The GetCursorPos (& amp; Point);
HWND HWND=: : WindowFromPoint (point);
WCHAR buf [MAX_PATH]={0};
DWORD dProcessId;
GetWindowThreadProcessId (hWnd, & amp; DProcessId);
Bool flag=GetProcessFullPathByPID (dProcessId, buf);
Buf is the path, but I get is not the path to the file, but the path of the excel corresponding exe,
Now can also use a function GetWindowLong (hWnd, GWL_HINSTANCE) for excel file handle to an instance of the
Excuse me, what to do to get file path, for example, D: \ Test. XLSX???
Thank you very much
}
CodePudding user response:
GetPathName ();CodePudding user response:
HANDLE the proc=OpenProcess (PROCESS_ALL_ACCESS, FALSE, dProcessId);EnumProcessModules (proc, module, sizeof (module), & amp; Men);
GetModuleFileNameEx (proc, module (nn), drpath, MAX_PATH);
I wrote, I'm the mouse to click the WPS forms, file is the Test. The XLSX, some get is the path to the DLL module, get less than the Test. The XLSX path, the file it may not seem like a concept and module
CodePudding user response:
GetWindowTextCodePudding user response:
GetWindowText can access to the file name, for example, the Test. XLSX, but can't access the file path