4
I developed an application on Lazarus on the linux platform for printing reports, now I need to click on the file with any extension, ex arquivo.gsa
, open my application Lazarus on linux. In windows, it was not so complicated I used this code:
function RegisterLink(Ext, FType, FriendlyName, Cmd: PChar): Boolean;
//
// Tenta associar um tipo de arquivo a um aplicativo
//
// Ext: Extensão a ser registrada.
// FType: Categoria do arquivo
// FriendlyName: Tipo de arquivo
// Cmd: linha de comando para abrí-lo
// RegisterLink('.Bsd','ArqInutil','Arquivo inútil','C:\Windows\Notepad.exe "%1"')
//
var
Key: HKey;
SZEntry: Array[0..255] of Char;
SZSize: LongInt;
begin
Result := True;
if RegOpenKey(HKEY_CLASSES_ROOT,Ext,Key) = ERROR_SUCCESS then
begin
SZSize := SizeOf(SZEntry);
RegQueryValue(Key,'',SZEntry,SZSize);
StrCat(SZEntry,'\Shell\Open\Command');
if RegOpenKey(HKEY_CLASSES_ROOT,SZEntry,Key) = ERROR_SUCCESS then
begin
SZSize := SizeOf(SZEntry);
RegQueryValue(Key,'',SZEntry,SZSize);
if (StrIComp(SZEntry,Cmd) = 0) then // and (MessageDlg('A extensão "'+StrPas(Ext)+ '" já está associada para '+copy(StrPas(SZEntry),1,22)+#13+'Você deseja substituir a associação atual por esta?', mtConfirmation, [mbYes,mbNo],0) <> IDYES) then
begin
Result := False;
Exit;
end;
end;
end;
RegCreateKey(HKEY_CLASSES_ROOT,Ext,Key);
RegSetValue(Key,'',REG_SZ,FType,StrLen(FType));
RegCreateKey(HKEY_CLASSES_ROOT,FType,Key);
RegSetValue(Key,'',REG_SZ,FriendlyName,StrLen(FriendlyName));
StrCat(StrCopy(SZEntry,FType),'\Shell\Open\Command');
RegCreateKey(HKEY_CLASSES_ROOT,SZEntry,Key);
RegSetValue(Key,'',REG_SZ,Cmd,StrLen(Cmd));
end;
then I pass this information to the function:
RegisterLink('.gsa','ArqGestor','Archivos del Informe',pchar(application.exename+' "%1"'))
Now the problem is how to do this in linux?
There must be some way to associate a file containing text to open in a Lazarus application. In the name of this file contains some information from the page that will be printed. Even if I use the " open with ", I need to get the file name in the execution to pass the parameters to the printer by Lazarus.
– Gustavo
Depends it will help me associate my file . gsa containing text and move to my application developed in Lazarus?? I need to click on this file and open my program already passing the text of this file to a Tmemo, explain to me better what this pkge does. Thanks for the help
– Gustavo
Would you have any tutorial on this? some example? if possible. Thank you
– Gustavo
thank you, wait
– Gustavo