473,395 Members | 1,468 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Creating Printer Port in VB

I need to create a file printer port. I can do it using the PRNADMIN.DLL
like so:

Public Sub CreateFilePort(ByVal FilePath As String)
Dim PRNADMIN As New PRNADMINLib.PrintMaster
Dim port As New PRNADMINLib.Port
port.PortName = FilePath
port.PortType = 3 'Standard Local Port
PRNADMIN.PortAdd(port)
End Sub

Is there any way I can do it without using this COM assembly?
Feb 23 '07 #1
4 10208
WMI will do it.

You could also use the Microsoft scripting runtime (is also COM but will
almost allways be installed)

There might also be a command line way with PRINTUI.DLL

"Terry Olsen" <to******@hotmail.comwrote in message
news:O1**************@TK2MSFTNGP05.phx.gbl...
>I need to create a file printer port. I can do it using the PRNADMIN.DLL
like so:

Public Sub CreateFilePort(ByVal FilePath As String)
Dim PRNADMIN As New PRNADMINLib.PrintMaster
Dim port As New PRNADMINLib.Port
port.PortName = FilePath
port.PortType = 3 'Standard Local Port
PRNADMIN.PortAdd(port)
End Sub

Is there any way I can do it without using this COM assembly?

Feb 23 '07 #2
I've searched through WMI but only found Win32_Printer and
Win32_TCPIPPrinterPort, neither will let me add the kind of port that I
want. Do you know what WMI class will let me add the port?

The PRNADMIN.DLL, according to its documentation, is a wrapper around
PRINTUI.DLL. I tried to figure out how to add the port directly with
PRINTUI.DLL but was unsuccessful there as well.

Ideally, I'd like to be able to do it using WMI or Win32Api, that way I
don't have to rely on an external DLL.

"Michael M." <no****@mike.comwrote in message
news:O%****************@TK2MSFTNGP03.phx.gbl...
WMI will do it.

You could also use the Microsoft scripting runtime (is also COM but will
almost allways be installed)

There might also be a command line way with PRINTUI.DLL

"Terry Olsen" <to******@hotmail.comwrote in message
news:O1**************@TK2MSFTNGP05.phx.gbl...
>>I need to create a file printer port. I can do it using the PRNADMIN.DLL
like so:

Public Sub CreateFilePort(ByVal FilePath As String)
Dim PRNADMIN As New PRNADMINLib.PrintMaster
Dim port As New PRNADMINLib.Port
port.PortName = FilePath
port.PortType = 3 'Standard Local Port
PRNADMIN.PortAdd(port)
End Sub

Is there any way I can do it without using this COM assembly?


Feb 24 '07 #3
I am sure I gave you the WMI code for this arounf 10 days ago Tery. If it
wasn't you then it was another user

--
Newbie Coder
(It's just a name)
Feb 24 '07 #4
You didn't give me code, you gave me links to WMI reference pages. I've
searched through all those pages. I used the WMI Code Creator extensively to
search for anything related to adding a printer port but came up empty. If
you have a specific class for me to look at, i'd appreciate it.

I did, however, get it to work using the AddPortEx API call, though this
call is "obsolete" according to MSDN. Here's the code:

<StructLayout(LayoutKind.Sequential)_
Public Structure PORT_INFO_1
Dim pPortName As String
End Structure

Public Declare Function AddPortEx Lib "winspool.drv" Alias "AddPortExA"
(ByVal pName As String, ByVal pLevel As Integer, ByRef lpBuffer As
PORT_INFO_1, ByVal pMonitorName As String) As Integer

Dim p1 As PORT_INFO_1
p1.pPortName = "C:\PrinterFile.txt"
API.apiAddPortEx(Nothing, 1, p1, "Local Port")

Now I need to figure out how to delete a port. There is a DeletePort API
call, but it throws up a dialog for the user. I want to delete the port
without user intervention. There isn't a DeletePortEx call that I can find
(as a counterpart to the AddPortEx call).

"Newbie Coder" <ne*********@spammeplease.comwrote in message
news:%2***************@TK2MSFTNGP02.phx.gbl...
>I am sure I gave you the WMI code for this arounf 10 days ago Tery. If it
wasn't you then it was another user

--
Newbie Coder
(It's just a name)


Feb 25 '07 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Lizard King | last post by:
Hi. I have a computer running a third party software (POS). The thing is this application opens the printer port and I need to use another program while the first one is still running. Since...
1
by: Bow Hunter | last post by:
Greetings! Is there a way to send data to and read it directly from the parallel printer port using VB6? We did this years ago on a 8088 using assembly language. I need to be able to set each bit...
0
by: Soon Lee | last post by:
Hi all any one know of any ways to read and write to a printer port using vb.net Please kindly enlighten me Thank you -- WebSite : http://soonlee.agreatserver.com
3
by: Joca | last post by:
Hi, I have a process system that generate events and send them to a printer port, and in the end a printer writes it as a text line on a paper. I would like to chatch this text line...
6
by: Bradley1234 | last post by:
What is the way to send/read bits to the printer port at the hex 3F8-3FF or any other legacy io space?? Does C# include the methods to drive the printer or other ports? tia
0
by: Gustavo | last post by:
Hy everybody !! C# allow me to develop a printer port monitor ? If yes have You a good place to look for samples and information ? Thanks Gustavo
0
by: H. Williams | last post by:
Is it possible to create a new printer port at runtime and then set a printer to the new port?
4
by: jimatqsi | last post by:
I am trying to print UPS shipping labels using a Zebra label printer. Apparently these printers have the label form programmed into the firmware and all I have to do is send a particular string of...
1
by: JAYATHILAKA | last post by:
pls Help me to Liting a LED using Printer Port, & VB6.0 IF u can send method.
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.