Home > Software engineering > Question [100], you double-click to open the file operation of multi-process communication process?
Question [100], you double-click to open the file operation of multi-process communication process?
Time:11-09
Recently met a don't know much about business, but I think there should be a lot of people have written and have a relatively common methods to achieve, but I didn't find baidu, so here I ask leaders to guide the younger brother, thank you Is this File type has been associated with good, if you don't start the program, double-click the file to start the program,
int APIENTRY WinMain (HINSTANCE HINSTANCE, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) { STD: : string targetfile=lpCmdLine;//registered file type, double click on the corresponding file types, the value will receive the target file
//to find the main form is already running The HWND HWND=: : FindWindow (NULL, _T (" MainWnd ")); If (HWND!=NULL) { //if the user open the associated file by double-clicking on, then try to open the file {if (targetfile. The size ()) //const char * tf="you are a god";//success //const char * tf=targetfile. Data ();//failure
//MessageBox (HWND, tf, NULL, 0); Display correctly//all successful, double-click the file path : : SendMessage (HWND, WM_OPENTARGETFILE, 0, (LPARAM) tf); } return 0; } The else { //main form didn't run, just run the main form CMainWnd * pFrame=new CMainWnd; If (pFrame==NULL) return 0; PFrame - & gt; Create (NULL, _T (" MainWnd "), UI_WNDSTYLE_FRAME, 0 l, 0, 0, 990, 690); PFrame - & gt; CenterWindow (); PFrame - & gt; ShowModal (); The delete pFrame;
return 0; } }
This value, is the path I double click the file to this MainWnd, this step is difficult to me, see the code above, I specific assignment is successful by value, but with targetfile is washed-up, whether c_str () or data () all can not pass, but the pop-up window when it is right, asked a also write code, he than I know a little about, but he didn't write this, he said there should be multiple processes, how many how many files open process, not reach values because across processes, inter-process communication, I want to know, everyone here is how to deal with, is here, double-click the file transfer value is a multi-process communication? Or how to preach, modesty and guidance!
CodePudding user response:
To //allow the user to through Windows file manager to open data file EnableShellOpen () : Then search RegisterShellFileTypes himself
CodePudding user response:
Across processes, can consider to use clipboard
CodePudding user response:
Under the WM_COPYDATA can also refer to Using the Data Copy