After trial & error and a review of FAQs, etc. I came up with the following, which will open Crystal Reports .Rpt files automatically, through an file association with a 3rd party Report Viewer. In case the files have been moved, or the network or drive mappings weren't available, I wanted to display an error message:
procedure TForm1.Button1Click(Sender: TObject);
var
ReturnValue : THandle;
begin
ReturnValue := 0;
ReturnValue := ShellExecute(0, 'open', pchar('V:\DDSO Reporter\Organization.Rpt'), nil, nil, SW_NORMAL);
if ReturnValue < 32 then
showmessage('The requested file cannot be opened at this time. Please check your network connections and Drive Mappings.')
end;
If I read the WINApi help correctly, the return value will be less than 32 if there was a problem opening the document (it had been moved, or the network was down, etc., and (I'm assuming) more than 32 (the Handle assigned by Windows) if it was alright. Does anyone know if this is the most effective way to do this. This does work, but I'm not sure it's the best way to do it.
procedure TForm1.Button1Click(Sender: TObject);
var
ReturnValue : THandle;
begin
ReturnValue := 0;
ReturnValue := ShellExecute(0, 'open', pchar('V:\DDSO Reporter\Organization.Rpt'), nil, nil, SW_NORMAL);
if ReturnValue < 32 then
showmessage('The requested file cannot be opened at this time. Please check your network connections and Drive Mappings.')
end;
If I read the WINApi help correctly, the return value will be less than 32 if there was a problem opening the document (it had been moved, or the network was down, etc., and (I'm assuming) more than 32 (the Handle assigned by Windows) if it was alright. Does anyone know if this is the most effective way to do this. This does work, but I'm not sure it's the best way to do it.