I have an exe loaded as a service on NT. Many thanks to the help received from this forum in creating exe's to run as a service.
Now, I need this application to print to the default printer. My application uses the tprinter class and the Fivewin report class.
During the print attempt I receive the following message.
MsgStop( "There are no printers installed!" + CRLF + ;
"Please exit this application and install a printer." )
This comes from the printer.prg (tprinter class) from the following lines of code.
if ::hDC != 0
aOffset := PrnOffset( ::hDC )
::nXOffset := aOffset[1]
::nYOffset := aOffset[2]
::nOrient := ::GetOrientation()
elseif ComDlgXErr() != 0
MsgStop( "There are no printers installed!" + CRLF + ;
"Please exit this application and install a printer." )
::nXOffset := 0
::nYOffset := 0
else
::nXOffset := 0
::nYOffset := 0
::nOrient := DMORIENT_PORTRAIT
endif
My question is, how can I utilize the printer class from an application running as a service? Or, how can I "install" a printer which will be available to services that are running?
Thanks in advance.
printing from .exe running as a service
- don lowenstein
- Posts: 196
- Joined: Mon Oct 17, 2005 9:09 pm
- Contact:
printing from .exe running as a service
Don Lowenstein
www.laapc.com
www.laapc.com
- AngelSalom
- Posts: 664
- Joined: Fri Oct 07, 2005 7:38 am
- Location: Vinaros (Castellón ) - España
- Contact:
Can you tell me how you make the application run as a service?
Angel Salom
http://www.visionwin.com
---------------------------------------------
fwh 19.05 - harbour 3.2 - bcc 7.0
http://www.visionwin.com
---------------------------------------------
fwh 19.05 - harbour 3.2 - bcc 7.0
- don lowenstein
- Posts: 196
- Joined: Mon Oct 17, 2005 9:09 pm
- Contact:
run exe as a service
Don Lowenstein
www.laapc.com
www.laapc.com
- James Bott
- Posts: 4654
- Joined: Fri Nov 18, 2005 4:52 pm
- Location: San Diego, California, USA
- Contact:
- don lowenstein
- Posts: 196
- Joined: Mon Oct 17, 2005 9:09 pm
- Contact:
Thanks.
Currently I perform my printing using a .pdf tool that I think you may have alerted me about.
Image2PDF.dll -- works wonderfully. I use the FWH report object - modified 2 lines of code to control the location and names of the .emf files, and then convert to .pdf documents and deliver via the web.
I will checkout your link as well.
Currently I perform my printing using a .pdf tool that I think you may have alerted me about.
Image2PDF.dll -- works wonderfully. I use the FWH report object - modified 2 lines of code to control the location and names of the .emf files, and then convert to .pdf documents and deliver via the web.
I will checkout your link as well.
Don Lowenstein
www.laapc.com
www.laapc.com
- AngelSalom
- Posts: 664
- Joined: Fri Oct 07, 2005 7:38 am
- Location: Vinaros (Castellón ) - España
- Contact:
Don, thanks for your help. I make the application right, but now i've a problem ...
I've installed the exe as a service with the srvany.
Into the .prg i use these functions :
//------------------------------
Function ServiceProcess( mode )
//------------------------------
Local nProcessId := 0
Default mode := 0
nProcessId := GCP( )
If Abs( nProcessId ) > 0
RSProcess( nProcessId, mode )
Endif
RETURN
//----------------------------------------------------
DLL32 FUNCTION RSProcess(npID AS LONG ,;
nMode AS LONG ) AS LONG ;
FROM "RegisterServiceProcess" LIB "kernel32.DLL"
//----------------------------------------------------
//----------------------------------------------------
DLL32 FUNCTION GCP() AS LONG;
FROM "GetCurrentProcessId" LIB "kernel32.dll"
//----------------------------------------------------
... and in then Function Main()
ServiceProcess(1)
Well, it's allright, but when i try to start the service, i've got an error message : (error 1053 : service is not responding) (windows 2003 server).
Curiously, the application starts (i make a log file in the app and really works), but the service ends and the application is out!
Thanks ... and sorry for my english !
I've installed the exe as a service with the srvany.
Into the .prg i use these functions :
//------------------------------
Function ServiceProcess( mode )
//------------------------------
Local nProcessId := 0
Default mode := 0
nProcessId := GCP( )
If Abs( nProcessId ) > 0
RSProcess( nProcessId, mode )
Endif
RETURN
//----------------------------------------------------
DLL32 FUNCTION RSProcess(npID AS LONG ,;
nMode AS LONG ) AS LONG ;
FROM "RegisterServiceProcess" LIB "kernel32.DLL"
//----------------------------------------------------
//----------------------------------------------------
DLL32 FUNCTION GCP() AS LONG;
FROM "GetCurrentProcessId" LIB "kernel32.dll"
//----------------------------------------------------
... and in then Function Main()
ServiceProcess(1)
Well, it's allright, but when i try to start the service, i've got an error message : (error 1053 : service is not responding) (windows 2003 server).
Curiously, the application starts (i make a log file in the app and really works), but the service ends and the application is out!
Thanks ... and sorry for my english !
Angel Salom
http://www.visionwin.com
---------------------------------------------
fwh 19.05 - harbour 3.2 - bcc 7.0
http://www.visionwin.com
---------------------------------------------
fwh 19.05 - harbour 3.2 - bcc 7.0
- don lowenstein
- Posts: 196
- Joined: Mon Oct 17, 2005 9:09 pm
- Contact:
I think the .exe which is spawned by the service should run continously controlled by some sort of loop or timer. I usually terminate the .exe via a 'trigger' such as writing a txt file from another process to instruct the loop to end.
Note that the srvany.exe service process simply loads yourapplication.exe automatically, upon server startup. It does not continously load the application. If you terminate the .exe the service may still continue to run. Terminating the service will terminate your .exe, but terminating your .exe will not terminate the service necessarily.
I use the service (srvany.exe) as a method to automatically load an exe process upon server startup.
Note that the srvany.exe service process simply loads yourapplication.exe automatically, upon server startup. It does not continously load the application. If you terminate the .exe the service may still continue to run. Terminating the service will terminate your .exe, but terminating your .exe will not terminate the service necessarily.
I use the service (srvany.exe) as a method to automatically load an exe process upon server startup.
Don Lowenstein
www.laapc.com
www.laapc.com