The report generated in the web server is printed out on the network shared printer

From: peter (pey9076@hotmail.com)
Date: 06/22/02


From: "peter" <pey9076@hotmail.com>
Date: Sat, 22 Jun 2002 09:44:52 +0800


Hi, all

There are some local printers and network shared printers installed in my
web server.

I created a web application, it would call a function in a DLL's to finish
the report print work.
The print functionality is done in the DLL's(PrintPaperWork.DLL). In fact,
there is another calling
and the printing report work is finished in the PB class(using the print
method of the datawindow):

****************************************************************************
****************************************************************************
***
PrintPaperWork.DLL source codes:
****************************************************************************
****************************************************************************
***
   Private Const sPB_KEY_VALUE_CREATE_SHIPMENT =
"CLSID\{08493163-D132-40B2-9FFF-24B5AE5B5D1B}\Powerbuilder\LibraryList"
    Private Const sPB_KEY_VALUE_PRINT_MAIN_MANIFEST =
"CLSID\{23F380AB-6B8C-47B8-8A8D-F84574D91E08}\Powerbuilder\LibraryList"
    Private Const sPB_KEY_VALUE_PRINT_OTHER_DOCS =
"CLSID\{0DBE98A8-8FB9-444D-AF7F-7073B524AC3E}\Powerbuilder\LibraryList"

    Private bCheck As Boolean

    Private PBAppObjectCreate As Object
    Private MyPbObjectCreate As Object

    Private strPrintDoc As String
    Private strReturn As String

Public Function PrintOtherDocs(ByVal sWorkorderNo As String, ByVal sGenrtr
As String, ByVal sChoiceUser As String, ByVal sDate As String, ByVal sTime
As String) As String

   Set PBAppObjectCreate = CreateObject("Powerbuilder.Application.7")

    bCheck = REGTool5.GetKeyValue(REGTool5.HKEY_CLASSES_ROOT,
sPB_KEY_VALUE_PRINT_OTHER_DOCS, "", strPrintDoc)
    PBAppObjectCreate.LibraryList = strPrintDoc
    PBAppObjectCreate.MachineCode = False

    Set myPbObject = PBAppObjectCreate.CreateObject("nvo_cont_center")

    strReturn = myPbObject.uf_other_docs(sWorkorderNo, sGenrtr, sChoiceUser,
sDate, sTime)

    Set myPbObject = Nothing
    Set PBAppObjectCreate = Nothing

    PrintOtherDocs = strReturn

End Function

Public Function PrintMainManifest(ByVal sWorkorderNo As String, ByVal
sGenrtr As String, ByVal sChoiceUser As String, ByVal sDate As String, ByVal
sTime As String, ByVal YesNo As String) As String
   Set PBAppObjectCreate = CreateObject("Powerbuilder.Application.7")

    bCheck = REGTool5.GetKeyValue(REGTool5.HKEY_CLASSES_ROOT,
sPB_KEY_VALUE_PRINT_MAIN_MANIFEST, "", strPrintDoc)
    PBAppObjectCreate.LibraryList = strPrintDoc
    PBAppObjectCreate.MachineCode = False

    Set myPbObject = PBAppObjectCreate.CreateObject("nvo_control_center")

    strReturn = myPbObject.uf_control_center(sWorkorderNo, sGenrtr,
sChoiceUser, sDate, sTime, YesNo)

    Set myPbObject = Nothing
    Set PBAppObjectCreate = Nothing

    PrintMainManifest = strReturn

End Function

Public Function CreateShipment(ByVal sGenrtr As String, ByVal sWorkorderNo
As String, ByVal sDate As String, ByVal sTime As String, ByVal sChoiceUser
As String, sReCreateShipment As String) As String
   Set PBAppObjectCreate = CreateObject("Powerbuilder.Application.7")

    bCheck = REGTool5.GetKeyValue(REGTool5.HKEY_CLASSES_ROOT,
sPB_KEY_VALUE_CREATE_SHIPMENT, "", strPrintDoc)
    PBAppObjectCreate.LibraryList = strPrintDoc
    PBAppObjectCreate.MachineCode = False

    Set myPbObject = PBAppObjectCreate.CreateObject("nvo_create_shipment")

    strReturn = myPbObject.uf_create_shipment(sGenrtr, sWorkorderNo, sDate,
sTime, sChoiceUser, sReCreateShipment)

    Set myPbObject = Nothing
    Set PBAppObjectCreate = Nothing

    CreateShipment = strReturn
End Function

****************************************************************************
****************************************************************************
***

If i select a local printer, the report will be printed out in the web
server successfully . But if i select
a network shared printer, the report will not be printed out. I hope that my
report will be printed out
on the network printer not the local printer. How should i do ?

I think the security causes the problem. How could i solve the problem?

In my *.aspx, I could just get the local printers not the network shared
printers. The codes in VB.net are as follows :

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
        System.EventArgs) Handles Button1.Click
            Dim pkInstalledPrinters As String

            Dim colPrinterList As New Collection()

            For Each pkInstalledPrinters In
PrinterSettings.InstalledPrinters
                colPrinterList.Add(pkInstalledPrinters)
            Next
End Sub

Any help, tips, links are very appreciated !

You'd better give me some source codes .

Thanks in advance.

Peter
pey9076@hotmail.com