Home > Mobile >  Qt implementation file associated with the application
Qt implementation file associated with the application

Time:09-25

Has achieved after the double-click the file to open the associated application, but is now set up the application can only open one, then the problem to:
If the application is first opened, and then double-click the file to how to pass the information of the file to process? Which the great spirit guide, thank you!

Is the realization of the code below:
//registry associated files
QString strRegeditPath="HKEY_CURRENT_USER \ \ Software \ \ Classes";
QString className="km. KTF";
QString appPath=QApplication: : applicationFilePath ();
AppPath. Replace ('/', '\' \ ');
QString extName=". KTF ";
QString extDesName="KTF file";

QSettings setting (strRegeditPath, QSettings: : NativeFormat);
//whether the registry already exists
QString qsValue=https://bbs.csdn.net/topics/setting.value ("/" + className + "/", true). The toString ();
if (! QsValue. IsEmpty ()) {
QDebug () & lt; <" QsValue="https://bbs.csdn.net/topics/return;
}

//in... Classes under the category to create a new category, and set up the call parameters of the category to open the file
Setting. SetValue ("/" + className + "/Shell/Open/Command/.", "" "+ appPath +" \ "" % 1 \ "");
//file type description
Setting. SetValue ("/" + className + "/", extDesName);
//set the default icon of the class the default icon
Setting. SetValue ("/" + className + "/DefaultIcon/.", appPath +, "0");
//associated ext and categories
Setting. SetValue ("/" + extName +/OpenWithProgIds "/" + className, "");
//save the modified immediately
Setting. The sync ();

CodePudding user response:

Simple method is: use the Shared memory, the memory set in the identification, read the logo can judge whether the program has been running,

CodePudding user response:

reference table 1/f, soot response:
simple method is: use the Shared memory, the memory set in the identification, read the logo can judge whether the program has been running,

This is to set up program to run only one, I want to ask is if the program has already opened up, after I double click on the file, how to put the documents related to open the program, rather than the other open, like to run the program word, and then double-click a word document, how to open this document directly in the word to open in the program
  •  Tags:  
  • Qt
  • Related