PDA

View Full Version : Launch app by opening a file



Windsoarer
27th May 2009, 21:37
This beginner's question must surely have been asked and aswered already, however the search through this forum gives nothing.

I have created the links to associate a given file extension to my app. Having done that, is there a method to process the parameters in main(int argc, char *arg[]) to get the file name ?

The *char array apparently is the app path concatenated with the file path, but is it possible to get the file path only ?

Thanks in advanced for any help

andre

Windsoarer
28th May 2009, 05:47
I finally figured it out



int main(int argc, char *argv[])
{
QString PathName, Extension;
PathName=argv[1];

Extension = PathName.right(4);
if(Extension.compare(".ext",Qt::CaseInsensitive)==0)
{
LoadFile(PathName);
}
}

aamer4yu
28th May 2009, 06:22
You could also have used QFileInfo::suffix