Club Builder - Foros de discusión Club Builder
Foro de C++Builder en español
 
 FAQFAQ   BuscarBuscar   MiembrosMiembros   Grupos de UsuariosGrupos de Usuarios   RegistrarseRegistrarse 
 PerfilPerfil   Entra para ver tus mensajes privadosEntra para ver tus mensajes privados   EntrarEntrar 

Asignar extensiones a mi programa

 
Publicar nuevo tema   Responder al tema    Foros de discusión -> Consultas
Ver tema anterior :: Ver tema siguiente  
Autor Mensaje
Mensaje    Asunto: Asignar extensiones a mi programa Responder citando

Como puedo hacer para que una extension de un archivo me la asocie a mi programa y la abra con mi programa es decir lo mismo q sucede con el .doc y el Word.

Gracias de antemano

Volver arriba
Mensaje    Asunto: Asignar extensiones a mi programa Responder citando

Saludos hermes, aki te pongo un codigo ke encontre hace tiempo, es largo, pero esta explicado. Espero ke te sirva, Wink

NOTA: Parece desordenado, pero simplemente copia y pega en word o notepad...

Register
the .fjf file extension
Create
a new instance of the Registry class (you
don't have to do it with pointers but I like
it better this way Wink
TRegistry*
thisReg = new TRegistry();
Set the root key to
HKEY_CLASSES_ROOT, which is where file associations
are stored
thisReg->RootKey
= HKEY_CLASSES_ROOT;
Open/Create the key
for the file extension you want to change/register
thisReg->OpenKey(".fjf",
true);
Set
the default value to the program you want
to associate the extension with NB: This can
be what ever you want. The name (here FormLoader)
is just a link to the next key we are going
to create
thisReg->WriteString("",
"FormLoader");
Close Key
thisReg->CloseKey();
Write
the default Open command (here we open/create
the key with the association name from above)
thisReg->OpenKey("FormLoader",
true);
Set
the desciption of the file association
thisReg->WriteString("",
"FormLoader Jobfile");
Create
Key "shell" and set "open"
as default command (which is actually the
FormLoader->shell key Wink
thisReg->OpenKey("shell",
true);
thisReg->WriteString("", "open");

Open
the "Open" key (which is actually
the FormLoader->shell->open key Wink
thisReg->OpenKey("open",
true);
Write
the text (which will be shown in the popup
menu for the object on the explorer)
thisReg->WriteString("",
"&Open");
Create
Key "command", which is what is
caried out if the user select "Open"
--- *
thisReg->OpenKey("command",
true);
Write
what should be done when "Open"
is choosen ParamStr(0) is the name and path
to my program %1 is the paramter to my program.
This means that my program will be started
with the object, on which we have choosen
"Open," as parameter.
thisReg->WriteString("",
ParamStr(0)+" \"\%1\"");
Close
Key
thisReg->CloseKey();
Write
Open batch command
Here
is shown how to create an extra command for
your extension.
thisReg->OpenKey("FormLoader",
true);
thisReg->OpenKey("shell", true);
thisReg->OpenKey("open batch",
true);
thisReg->WriteString("", "Open
&Batch");
thisReg->OpenKey("command", true);
thisReg->WriteString("", ParamStr(0)+"
-b \"\%1\"");
thisReg->CloseKey();
Set
default icon
This
is the icon that will be given each object/file
that has extension ".fjf"
thisReg->OpenKey("FormLoader",
true);
thisReg->OpenKey("DefaultIcon",
true);
Here
is set the icon to the 2 icon resource in
my programs exe file. To give the objects/files
the same icon as your own program just write
thisReg->WriteString("", ParamStr(0)+",0");
instead
thisReg->WriteString("",
ParamStr(0)+",1");
Clean
up
delete
thisReg;
Autor: Jeppe Cramon

Volver arriba
Mostrar mensajes de anteriores:   
Cambiar a:  
No puedes publicar temas nuevos en este foro
No puedes responder a temas en este foro
No puedes editar tus mensajes en este foro
No puedes borrar tus mensajes en este foro
No puedes votar en las encuestas de este foro


Hosting WordPress Indedmedia desde 3,99 €
© 2002–2026 Club Builder · Funciona con phpBB.