- PDF files

From: CFB Software <"CFB>
Date: Mon, 7 Feb 2005 22:27:34 +1030

----boundary-LibPST-iamunique-1355198126_-_-
Content-type: text/plain

Hi Robert,

A useful WinApi function for doing things like this is ShellExecute. I've
just tried the code below and it seems to work OK but needs cleaning up and
thorough debugging / testing.

Try these sample calls:

        Execute.Run('P:\MyProject\MySubsystem\MyComponentSpecification.pdf');
        Execute.Run('http://www.cfbsoftware.com/gpcp');
        Execute.Run('mailto:blackbox{([at]})nowhere.xy

The latter two might come as a surprise. What Windows does is run the
application that is *associated* with the filename.

Regards,
Chris Burrows
CFB Software
http://www.cfbsoftware.com/gpcp


(*-----------------------------------------------------------
   Warning - the following code is experimental and untested.
   Use at your own risk.
   Chris Burrows.
   CFB Software 7 Feb 2005
-----------------------------------------------------------*)
MODULE Execute;

IMPORT WinApi, ComTools, SYSTEM;

PROCEDURE ExecuteFile(hwnd: WinApi.HWND; IN FileName: ARRAY OF SHORTCHAR):
WinApi.HINSTANCE;
VAR
  pParams, pDir, pFileName: WinApi.PtrSTR;
  fileName: ARRAY 255 OF SHORTCHAR;
BEGIN
  fileName := FileName$;
  pParams := ComTools.NewEmptySString(0);
  pDir := ComTools.NewEmptySString(0);
  pFileName := ComTools.NewSString(fileName);
  RETURN WinApi.ShellExecute(hwnd, NIL, pFileName, pParams, pDir,
    WinApi.SW_SHOWNORMAL);
END ExecuteFile;

PROCEDURE Run*(IN FileName: ARRAY OF SHORTCHAR);
VAR
  h: WinApi.HINSTANCE;
BEGIN
  h := ExecuteFile(0, FileName);
END Run;

END Execute.
(*-----------------------------------------------------------*)

> -----Original Message-----
> From: blackbox{([at]})nowhere.xy
> Campbell, Robert D (UK Edinburgh)
> Sent: Monday, 7 February 2005 8:05 PM
> To: BlackBox Mailing List
> Subject: [BlackBox] - PDF files
>
>
>
>
> I have written a small Command to open a 'PDF' file.
> It works for me, but has several problems, in particular:
>
> 1 - A customer might have a different version of Acrobat.
> 2 - She might keep in in a different path
> 3 - or not have Acrobat
> 4 - or prefers to use GSview etc.
>
> It is also not memory safe!
>
> Does anyone know a better approach?
>
> Thanks
>
> Robert
>
>
>
> MODULE WandsAcrobat;
> IMPORT WinApi, SYSTEM;
> CONST
> Acrobat = 'C:\Program Files\Adobe\Acrobat 5.0\Reader\AcroRd32.exe ';
>
> PROCEDURE Display*(IN path, file: ARRAY OF CHAR);
> VAR
> cmd: WinApi.PtrSTR;
> BEGIN
> cmd :=
> '01234567890123456789012345678901234567890123456789012345678901234
> 567890123456789012345678901234567890123456789012345678901234567890
> 123456789012345678901234567890123456789012345678901234567890123456
> 7890123456789';
> cmd^ := Acrobat + SHORT(path + file);
> IF WinApi.WinExec(cmd, WinApi.SW_SHOW) = 0 THEN END
> END Display;
>
> END WandsAcrobat.
>
>
> DevDebug.Unload
>
>
> "WandsAcrobat.Display('P:\MyProject\MySubsystem','MyComponentSpeci
> fication.pdf')"
>
> ********************************************************************
> This email and any attachments are confidential to the intended
> recipient and may also be privileged. If you are not the intended
> recipient please delete it from your system and notify the sender.
> You should not copy it or use it for any purpose nor disclose or
> distribute its contents to any other person.
> ********************************************************************
>
> --- BlackBox

> --- send subject HELP or UNSUBSCRIBE to blackbox{([at]})nowhere.xy
>
>
>

--- BlackBox
--- send subject HELP or UNSUBSCRIBE to blackbox{([at]})nowhere.xy



----boundary-LibPST-iamunique-1355198126_-_-
Content-type: application/rtf
Content-transfer-encoding: base64
Content-Disposition: attachment; filename="rtf-body.rtf"

e1xydGYxXGFuc2lcYW5zaWNwZzEyNTJcZnJvbXRleHQgXGRlZmYwe1xmb250dGJsDQp7XGYwXGZz
d2lzcyBBcmlhbDt9DQp7XGYxXGZtb2Rlcm4gQ291cmllciBOZXc7fQ0Ke1xmMlxmbmlsXGZjaGFy
c2V0MiBTeW1ib2w7fQ0Ke1xmM1xmbW9kZXJuXGZjaGFyc2V0MCBDb3VyaWVyIE5ldzt9fQ0Ke1xj
b2xvcnRibFxyZWQwXGdyZWVuMFxibHVlMDtccmVkMFxncmVlbjBcYmx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ioq
KioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKlxwYXINCj5ccGFyDQo+IC0t
LSBCbGFja0JveFxwYXINCj4gLS0tIHNlbmQgc3ViamVjdCBIRUxQIG9yIFVOU1VCU0NSSUJFIHRv
IGJsYWNrYm94QG9iZXJvbi5jaFxwYXINCj5ccGFyDQo+XHBhcg0KPlxwYXINClxwYXINCi0tLSBC
bGFja0JveFxwYXINCi0tLSBzZW5kIHN1YmplY3QgSEVMUCBvciBVTlNVQlNDUklCRSB0byBibGFj
a2JveEBvYmVyb24uY2hccGFyDQpccGFyDQp9


----boundary-LibPST-iamunique-1355198126_-_---
Received on Mon Feb 07 2005 - 12:57:34 UTC

This archive was generated by hypermail 2.3.0 : Thu Sep 26 2013 - 06:28:25 UTC