Äquivalent zu VB's CreateObject? - Lazarus

Für Fragen zur Programmiersprache auf welcher Lazarus aufbaut
Antworten
kirchfritz
Beiträge: 214
Registriert: Mo 3. Jan 2011, 13:34
OS, Lazarus, FPC: Win11 (L 3.0 FPC 3.2.2)
CPU-Target: 64Bit
Wohnort: Nürnberg

Äquivalent zu VB's CreateObject? - Lazarus

Beitrag von kirchfritz »

Hallo,
kann mir jemand mit der Übersetzung des folgenden VBS Programms nach Lazarus helfen?
Das Programm setzt ein DocumentURI, einen ExitLevel und einen OutputFilePath.
Danach wird Execute aufgerufen und anschließend der ErrorCode untersucht.
An sich alles nichts Weltbewegendes.
Ich hab nur keine Ahnung wie ich VisualBasics CreateObject() nach Freepascal übersetzen soll und welchen Typ obj haben soll.
Kann mir da jemand helfen?

Code: Alles auswählen

 
'
'	XSL Formatter COM Interface sample program
'
'	The following indicates the standard sample for formatting XSL-FO
'	document and outputting to PDF.
'
'	Copyright 2004 Antenna House, Inc.
'
Dim obj
Set obj = CreateObject("XfoComCtl.XfoObj")
 
obj.DocumentURI = "c:\temp\sample.fo"
obj.ExitLevel = 4
obj.OutputFilePath = "c:\temp\sample1.pdf"
 
obj.Execute
 
If obj.ErrorCode <> 0 Then
	MsgBox "Formatting Error ----" & Chr(13) & "level = " & obj.ErrorLevel & Chr(13) &_
					"code = " & obj.ErrorCode & Chr(13) & "message = " & obj.ErrorMessage
Else
	MsgBox "Formatting finished: " & obj.OutputFilePath & " created"
End If
 
Set obj = Nothing
 

g3sh
Beiträge: 21
Registriert: Mi 3. Jul 2013, 10:04

Re: Äquivalent zu VB's CreateObject? - Lazarus

Beitrag von g3sh »

Hi,

den Anfang würde ich mal so probieren:

Code: Alles auswählen

uses comobj;
 
procedure TForm1.Button1Click(Sender: TObject);
var
  obj: OLEVariant;
begin
  obj:= CreateOleObject('XfoComCtl.XfoObj');
  .
  .
  .
end;   
noch ein Link: http://wiki.freepascal.org/Olevariant/de

MfG


Antworten