473,543 Members | 2,488 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.Pri ntMaster
Dim port As New PRNADMINLib.Por t
port.PortName = FilePath
port.PortType = 3 'Standard Local Port
PRNADMIN.PortAd d(port)
End Sub

Is there any way I can do it without using this COM assembly?
Feb 23 '07 #1
4 10238
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******@hotma il.comwrote in message
news:O1******** ******@TK2MSFTN GP05.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.Pri ntMaster
Dim port As New PRNADMINLib.Por t
port.PortName = FilePath
port.PortType = 3 'Standard Local Port
PRNADMIN.PortAd d(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_TCPIPPrin terPort, 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.co mwrote in message
news:O%******** ********@TK2MSF TNGP03.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******@hotma il.comwrote in message
news:O1******** ******@TK2MSFTN GP05.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.Pri ntMaster
Dim port As New PRNADMINLib.Por t
port.PortName = FilePath
port.PortType = 3 'Standard Local Port
PRNADMIN.PortAd d(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(L ayoutKind.Seque ntial)_
Public Structure PORT_INFO_1
Dim pPortName As String
End Structure

Public Declare Function AddPortEx Lib "winspool.d rv" 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.apiAddPortE x(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*********@sp ammeplease.comw rote in message
news:%2******** *******@TK2MSFT NGP02.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
9687
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 the other app has the printer port windows shows an error (path/file access error). Is there a way that two applications can share the printer port?
1
4764
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 high or low and also read in if switches on the parallel printer port are open or closed. Thanks for any help or advice. Don Woods
0
1101
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
5451
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 programatically and process it in my little application. I would like to know if there are any "Microsoft" objects or functions to use to get hold of the...
6
1904
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
1347
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
926
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
9614
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 text to the port the printer is connected to (USB) and voila, the printer makes the label correctly. How do I send unformatted text to a printer port...
1
1411
by: JAYATHILAKA | last post by:
pls Help me to Liting a LED using Printer Port, & VB6.0 IF u can send method.
0
7408
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7349
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7735
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
7688
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
5885
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5271
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
3391
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1817
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
968
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.