When I try to use the following code in ServiceMain (writing a Windows service) isobject returns false and the COM object is not initalized. If you call from within WINMAIN and use regdb as a global variable it will work.
Why can COM objects not be referenced in servicemain?
static regdb AS IRegDb
DIM L AS STRING
DIM N AS STRING
DIM f AS STRING
f=UCODE$("c:\temp\regdemo.regdb")
regdb = NEWCOM $PROGID_RegDbLib_RegDb
kill "c:\error.txt"
IF ISFALSE(ISOBJECT(regdb)) THEN
' Could not create an object refrence, exit the application
open "c:\error.txt" for output as 1
print#1,"error"
close 1
END IF
Why can COM objects not be referenced in servicemain?
static regdb AS IRegDb
DIM L AS STRING
DIM N AS STRING
DIM f AS STRING
f=UCODE$("c:\temp\regdemo.regdb")
regdb = NEWCOM $PROGID_RegDbLib_RegDb
kill "c:\error.txt"
IF ISFALSE(ISOBJECT(regdb)) THEN
' Could not create an object refrence, exit the application
open "c:\error.txt" for output as 1
print#1,"error"
close 1
END IF
Comment