Using COM objects

<< Click to Display Table of Contents >>

Navigation:  FindOnClick > FindOnClick For Advanced Users > Scripting >

Using COM objects

 

Just as with DLL's, you can use external COM objects. For example, the following uses the FileSystemObject that is available in Windows to create a text file and write to it:

 

var fs, a;

begin

  fs:=CreateOleObject('Scripting.FileSystemObject');

  try

    a:=fs.CreateTextFile('c:\testfile.txt', True);

    a.WriteLine('This is a test.');

    a.Close;

  finally

    fs:=Unassigned;

  end;

end;

 

Note at the end the COM object is set to Unassigned. This releases the COM object and frees memory.

 

 

 

<%SBCOPYRIGHT%>