Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Doesn' t anyone know??! ActiveX dll........

Status
Not open for further replies.

cturland

Programmer
Sep 25, 2000
66
GB
I've posted this a few times before but never had a reply, its still causing me problems!

I'm trying to access the available printers in an ActiveX dll on a web interface. This is a bit of sample code:

Function AvailPrinters() as String

dim PrintData as Printers
dim sPrinters$

For Each PrintData in Printers
sPrinters$ = Printdata.DeviceName & " " & Printdata.driverName & ","
Next

AvailPrinters = sPrinters$

End Function

When I call this function from a VB app it returns a comma separated string of all the printers available. I then tried to include this dll in an ASP page and it returns an error saying that it can't access the printers.

Not sure if this is important but when I call the API function 'GetUserName' in my VB app it returns my username but when I call it in Internet Explorer through my dll I get 'SYSTEM'.

I'm really stuck, I've also tried launching an exe that used the dll through an ASP page but still no luck.

Any help would be really appreciated,
Rgds,
Carl
 
This doesn't neccesarily have anything to do with the specific problem you're having but wouldn't a 'Printers' object be a collection, not a single printer? Therefore, in the code below you are in effect saying "for each printers
collection in the printers collection" not "for each printer in the printers collection". It doesn't seem to make sense unless you change the variable declaration to
dim PrintData as Printer.

Code:
dim PrintData as Printers
    dim sPrinters$

    For Each PrintData in Printers
Ruairi

Could your manufacturing facility benefit from real time process monitoring? Would you like your employees to be able to see up to the minute goal and actual production?
For innovative, low cost solutions check out my website.
 
The problem you are actually having (i think) is that when you use the ActiveX control in a VB program it uses your user as the current context and has access to the available printers.

When the control runs on the web server it runs as whatever user the service is running as (IUSR_MACHINE or localsystem or whatever) and doesn't have access to the printers.

Check the knowledge base for more information about printing from system services. I know there is info about it out there.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top