Need help wirh GetPrivateProfileString for printers (OpenInsight)
At 05 JAN 2000 02:57:36AM Barry Stevens wrote:
I need to get the LPTx for a network printer that has been captured to a printer port. The following code only works if local printer.
Which field in Default will give me the LPTx I need.
I am not at a network site at the moment to do a 'debug'.
Thank you
Barry
here is the code*
GetPrivateProfileString(DFT_SECTION$, DFT_KEY$, \00\, Default, Len(Default), INI_FILE$)
Default=Default 1, \00\
Lptr=field(Default,',',3)
Lptr-1,1='
code ends***
At 05 JAN 2000 03:56AM Oystein Reigem wrote:
Barry,
I assume the code you list checks the device entry of the windows section of Win.ini.
(equ INI_FILE$ to "win.ini": \00\
equ DFT_SECTION$ to "windows": \00\
equ DFT_KEY$ to "device" : \00\)
I'm on a network, with no local printer. My entry is
device=4.etg via gandalf,PSCRIPT,\\GANDALF\etg4
with not a hint of which port is used. (The 3rd field \\GANDALF\etg4 refers to our print server (GANDALF) instead. "etg4" means 4th floor, i.e the printer on the 4th floor, where my office is.) So you won't find it there.
I've scanned the rest of my Win.ini file for "LPT", but cannot find anything useful. But of course you can have a look at yours.
I run Win98. I suspect you'll have to look in the Registry to find what you need if you run Windows post 3.x.
- Oystein -
PS. Before you say "oh no, not another Tolkien fan" I must haste to tell that Gandalf is also a character in one of Ibsen's plays.
At 05 JAN 2000 10:05AM Donald Bakke wrote:
Barry,
We adapted the code found in the PRINTSETUP routine to find printers and ports without any problems (95, 98, and NT). I can't look at your code close enough to discover any problems but I know it can be done. Also remember that in Win9x/NT printers can be directed directly to resource locaters and therefore won't return LPTx at all.
At 05 JAN 2000 06:36PM Barry Stevens wrote:
]]printers can be directed directly to resource locaters and therefore won't return LPTx at all.«
Thats what I mean, but, if the capture printer port is used to direct to LPTx, where can I get that LPTx.
Barry
At 05 JAN 2000 07:57PM Bob Carten wrote:
If you have the windows scripting host then
you can write something that will list all the printer connections.
The following code should create a file listing all of the network printer connections. OI can then parse the file.
You can also use the AddPrinter ans SetDefaultPrinter method to force the printer you want.
Hope this helps
Bob
'VbScript
'Compiled from Microsoft Samples
'msdn.microsoft.com/scripting
Set fso=CreateObject("Scripting.FileSystemObject")
Set MyFile= fso.CreateTextFile("c:\testfile.txt", True)
Set WshNetwork=WScript.CreateObject("WScript.Network")
Set oPrinters=WshNetwork.EnumPrinterConnections
MyFile.WriteLine("About to List Printers")
MyFile.WriteLine("Printer Count= & oPrinters.Count())
For i=0 to oPrinters.Count -1
MyFile.WriteLine(oPrinters.Item(i))WScript.Echo oPrinters.Item(i)Next
MyFile.WriteLine("Listed Printers")
MyFile.Close
At 05 JAN 2000 10:19PM Donald Bakke wrote:
Hi Barry,
I'm not sure I am understanding your question. Hopefully Bob did and his response is more helpful than mine.
If the LPTx port has been captured, then you should just get LPTx returned. If the printer is not capturing a LPTx port but has it's port directly printing to a network resource locater then that resource name will be returned. Consequently, if the latter is true then there is no LPTx port at all that this printer is associated with.
At 06 JAN 2000 03:28AM Barry Stevens wrote:
(Thanks Bob and Don)
Don
Thanks for you continued interest (as usual)
My fault for not explaining fully
]]port directly printing to a network resource locater codes correctly if I select, printer on, print,printer off.
Barry
At 06 JAN 2000 09:18AM Donald Bakke wrote:
Barry,
Aha, I think we are tracking now. The problem you are having is that even though you have captured the LPTx port as you described, this LPTx port is still not being assigned to the printer you are using. Your method still leaves the network resource as the direct port. Yes, LPT3 is captured but LPT3 is not the port assigned to your printer. Therefore GetPrivateProfileString won't return LPT3. AFAIK, there is no (easy) way to get the LPTx port that has been captured unless you assign a specific printer that LPTx port first.
So, for instance, given your example this is what I would do:
In the properties of the printer - Details tab, at the 'Print to the following port' (select) LPT3
Then click 'Capture printer port' - make 'Device' LPT3 and make 'Path' \\fileserver\dotmatrixprinter. Now your code should return LPT3 and the printer is truly printing to a capture LPT3 (so AREV can use it) rather than printing directly to a network resource.
At 06 JAN 2000 02:27PM David Pociu wrote:
Hi Barry,
I had the same problem with my system last year. I need to print multi-part forms on dot-matrix printers quite a bit and the generic text driver was awful.
What I ended up doing was to always print to LPT1 (in my case.Obviously it can be any LPT port). I would re-direct LPT1 to the dot-matrix printer at (the PC's) startup time using either "net use" on MS networks or "capture" on Novell. What that would do is let any DOS or direct LPT printing to go to the dot-matrix printer whereas the default Windows printer could be a network shared laserjet or anything else.
So far it has worked really well, and users know that their forms always come out on the dot-matrix whereas they can change between a variety of Windows printers for SLIST/Reporter reports.
Hope this helps a bit
Dave
At 07 JAN 2000 05:47AM Barry Stevens wrote:
Don
I went to the client site to-day to try and get it all working, find the printer, get the port, print to the port.
The capture printer port wasn't set to the lptx that I knew arev was using, now that was strange.
Debug after GetProfileString - nope - no LPTx.
Back to the printer properties - found in the drop down for the 'Print to the following port' - there was also a LPT3:\\server\dotmatrix - changed it to that - it all worked (the printer appear where it should.
Appears a 'connection' script is run at logon - it has the LPTx capture assignments in it.
I had to print directly to the dotmatrix because there was no NT driver for it, (it has to be dot matrix - 3part paper). Selecting the printer, printer on, print…,print off (via spooler) - would not format the codes correctly. It was setup with a 'Generic text' driver.
Funny -I just looked across to my dot matrix that I was using to test here - and it is a Star , the same as the client's.
Anyway, made converting the print programs a breeze, replaced print ……. with dosprint(………) and @(Boldon$) with (Boldon$)
Barry
At 07 JAN 2000 06:04AM Barry Stevens wrote:
David
Thank you for your confirmation that I am not nuts.
See my last posting in the 'Need help wirh …..' subject for a progress update .
]]direct LPT printing «
I assume 'oswrite Pline to Lptr'
Barry
At 07 JAN 2000 06:07AM Barry Stevens wrote:
]]See my last posting in the 'Need help wirh …..«
I am going nuts….sorry, didn't realise this was part of the chain.
Barry