[Gs-devel] Calling gsdll_* from Visual Basic

Mike_Lacey@cargill.com Mike_Lacey@cargill.com
Wed, 14 Feb 2001 13:42:52 +0000

Dear All,

I am writing a VB5 program to batch convert PS files to TIFF images for 

I have two problems (that I know of):

1 For a limited application such as this, what should be in the 
CallBack function? At the moment it is a stub that does nothing at all.

2 The executable grows by 30->70k each time a PS file is converted, am 
I calling the gsdll_* functions correctly? I have read the DLL 
documentation supplied with GS and *think* I am.... The code that calls 
the dll functions is below. I would appreciate comments or suggestions 
from anyone, particularly anyone who has used gsdll_* from VB. As far 
as I can tell the leak occurs when I convert the PS file (code below) 
but I am not convinced as yet.

My environment is:




Mike Lacey
Open Systems, Witham St Hughs.
+44 (0)7785 327 710 (mobile)
+44 (0)1522 556 243 (direct line)
+44 (0)1522 556 100 (switchboard)
www.tek-tips.com - Support for I.T. Professionals 

' GhostScript function declarations
Private Declare Function gsdll_revision Lib "gsdll32.dll" ( _
    lpString As String, _
    lpString As String, _
    gsrev As Long, _
    gsdate As Long _
) As Integer

Private Declare Function gsdll_init Lib "gsdll32.dll" ( _
    ByVal lpGsBack As Any, _
    ByVal hwnd As Long, _
    ByVal argc As Long, _
    argv As Long _
) As Integer

Private Declare Function gsdll_execute_begin Lib "gsdll32.dll" () As 

Private Declare Function gsdll_execute_cont Lib "gsdll32.dll" ( _
    ByVal pscommand As String, _
    ByVal commlen As Long _
) As Integer

Private Declare Function gsdll_execute_end Lib "gsdll32.dll" () As 

Private Declare Function gsdll_exit Lib "gsdll32.dll" () As Integer

this code is called for each PS file converted.

    llaArgV(0) = agGetAddressForObject&(Argv0(0))
    llaArgV(1) = agGetAddressForObject&(Argv1(0))
    llaArgV(2) = agGetAddressForObject&(Argv2(0))
    llaArgV(3) = agGetAddressForObject&(Argv3(0))
    llaArgV(4) = agGetAddressForObject&(Argv4(0))
    llaArgV(5) = agGetAddressForObject&(Argv5(0))
    llaArgV(6) = agGetAddressForObject&(Argv6(0))
    llaArgV(7) = agGetAddressForObject&(Argv7(0))
    llaArgV(8) = agGetAddressForObject&(Argv8(0))
    ' rcode = gsdll_revision(vbNullString, vbNullString, 0, 0)
    rcode = gsdll_init(AddressOf Callback, frmAutoFax.hwnd, 8, 
    initret = rcode
    rcode = gsdll_execute_begin()
    rcode = gsdll_execute_end()
    rcode = gsdll_exit()