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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Click on file --> Open my app (How do I do this?)

Status
Not open for further replies.

brivers

Programmer
Jun 8, 2004
14
0
0
US
Okay, I made an app with a "custom" file type and I need to know how to make it so that when I double-click a file of my type (.md5) it kicks off my app and loads the file.

I know how to make Windows kick off my app, but I'm not sure how to (in my program) get the name of the file from the OS so I can load the contents into the main window.

Any suggestions from anyone?

Thanks.
 
Look at "Dragging files into my exe's" thread down a notch or two, it describes exactly what your'e asking.

Totte
Keep making it perfect and it will end up broken.
 
here is what I do

(Example pulled from a project, you need to edit it)

Code:
#include <Registry.hpp>

void __fastcall TMainForm::SetRegistry()
{
 TRegistry *Registry = new TRegistry;
 Registry->RootKey = HKEY_CLASSES_ROOT;
 int Buffer = 0;

 if(Registry->KeyExists(".zs"))
 	Registry->DeleteKey("ZSLLite Server");

 /*Register ZDaemon Server File*/
 Registry->OpenKey(".zs", true); //true cause we want to create it if it doesnt exist.

 //link to file type's registerd key
 Registry->WriteString("", "ZSLLite Server");

 //Go back to root
 Registry->CloseKey();

 /*Open link to registerd file*/
 Registry->OpenKey("ZSLLite Server", true);
 Registry->WriteString("", "ZSLLite Server");
 Registry->WriteBinaryData("EditFlags", &Buffer, 1);

 /*Create Shell info*/
 Registry->OpenKey("shell", true);
 Registry->OpenKey("open", true);
 Registry->OpenKey("command", true);
 AnsiString tmp = "\""+Application->ExeName+"\" \"%1\"";
 Registry->WriteString("", tmp);

 //Back to r00t
 Registry->CloseKey();

 /*Back into link to set Default icon*/
 Registry->OpenKey("ZSLLite Server", false);

 //Check version, if diffrent, reset settings
 if(Registry->KeyExists("Version"))
 {
 	if(Registry->ReadString("Version") != Version)
 	{
  		Registry->CloseKey();
        	Registry->DeleteKey("ZSLLite Server");
        	SetRegistry();
        	return;
 	}
 }

 Registry->WriteString("Version", Version);
 Registry->OpenKey("DefaultIcon", true);
 Registry->WriteString("", Application->ExeName+",0"); //0 = this exe's first icon

 //Back to r00t
 Registry->CloseKey();

 /*Back to shell*/
 Registry->OpenKey("ZSLLite Server", false);
 Registry->OpenKey("shell", false);

 /*Create "Right-Click" menu 1 item*/
 Registry->OpenKey("Edit with ZDaemon Server Launcher", true);
 Registry->OpenKey("command", true);
 Registry->WriteString("", tmp);

 //Back to r00t
 Registry->CloseKey();

 /*Back to shell*/
 Registry->OpenKey("ZSLLite Server", false);
 Registry->OpenKey("shell", false);

 /*Create "Right-Click" menu 2 item*/
 Registry->OpenKey("Run Normal", true);
 Registry->OpenKey("command", true);
 Registry->WriteString("", tmp+" rn");

 //Back to r00t
 Registry->CloseKey();

 /*Back to shell*/
 Registry->OpenKey("ZSLLite Server", false);
 Registry->OpenKey("shell", false);

 /*Create "Right-Click" menu 3 item*/
 Registry->OpenKey("Run Hidden", true);
 Registry->OpenKey("command", true);
 Registry->WriteString("", tmp+" rh");

 //Back to r00t
 Registry->CloseKey();

 /*Back to shell*/
 Registry->OpenKey("ZSLLite Server", false);
 Registry->OpenKey("shell", false);

 /*Create "Right-Click" menu 4 item*/
 Registry->OpenKey("Run Minimized", true);
 Registry->OpenKey("command", true);
 Registry->WriteString("", tmp+" rm");

 //Back to r00t
 Registry->CloseKey();

 //Cleanup!
 delete Registry;
}

I hope that helped
-Richard
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top