|
You can use the EnumPrinters API
(Declaration)
<DllImport("winspool.drv", EntryPoint:="EnumPrinters", _
SetLastError:=True, CharSet:=CharSet.Ansi, _
ExactSpelling:=False, _
CallingConvention:=CallingConvention.StdCall)> _
Public Function EnumPrinters(<InAttribute()> ByVal Flags As EnumPrinterFlags, _
<InAttribute()> ByVal Name As String, _
<InAttribute()> ByVal Level As Int32, _
<OutAttribute()> ByVal lpBuf As IntPtr, _
<InAttribute()> ByVal cbBuf As Int32, _
<OutAttribute()> ByRef pcbNeeded As Int32, _
<OutAttribute()> ByRef pcbReturned As Int32) As Boolean
End Function
passing in the appropriate EnumPrinterFlags from:
<Flags()> _
Public Enum EnumPrinterFlags
PRINTER_ENUM_DEFAULT = &H1
PRINTER_ENUM_LOCAL = &H2
PRINTER_ENUM_CONNECTIONS = &H4
PRINTER_ENUM_FAVORITE = &H4
PRINTER_ENUM_NAME = &H8
PRINTER_ENUM_
PRINTER_ENUM_SHARED = &H20
PRINTER_ENUM_NETWORK = &H40
End Enum
|
|
|
|
|
Sir,
I was bit confusing on passing parameters to the function.Could you illustrate with an example please?
Thank You!
X
|
|
|
|
|
I have all this stuff built into a fairly large object model so it is a bit difficult to cut out just the bits that are needed, but it should look something a bit like:
Dim pcbNeeded As Int32
Dim pcReturned As Int32
Dim pPrinters As IntPtr
Dim pcbProvided As Int32 = 0
If Not EnumPrinters(EnumPrinterFlags.PRINTER_ENUM_NETWORK, String.Empty, 1, pPrinters, 0, pcbNeeded, pcReturned) Then
If pcbNeeded > 0 Then
pPrinters = Marshal.AllocHGlobal(pcbNeeded)
pcbProvided = pcbNeeded
If Not EnumPrinters(EnumPrinterFlags.PRINTER_ENUM_NETWORK, String.Empty, 1, pPrinters, pcbProvided, pcbNeeded, pcReturned) Then
Throw New Win32Exception
End If
End If
End If
If pcReturned > 0 Then
Dim ptNext As IntPtr = pPrinters
While pcReturned > 0
Dim pi1 As New PRINTER_INFO_1
Marshal.PtrToStructure(ptNext, pi1)
If Not pi1.pPrinterName Is Nothing Then
End If
ptNext = New IntPtr(ptNext.ToInt32 + Marshal.SizeOf(pi1))
pcReturned -= 1
End While
End If
If pPrinters.ToInt32 > 0 Then
Marshal.FreeHGlobal(pPrinters)
End If
However there's probably loads of declarations and namespaces missing from that - your best bet would be to download the latest source code form the printer usage monitoring application[^] and cut the bits you need out of that.
There is also more info on Randy Birch's site here[^]
|
|
|
|
|
Thanks for everything.
I really appreciate your help.
X
|
|
|
|
|
How to register a dll in a .net Application
|
|
|
|
|
The DLL's are automattically registered during installation.
or
if there is a problem then register it do the fillowing
1. open the dll file by double click on it
it will open the open with.. box
2. chosse the browse open to locate another applications
3. The choose the regsvr32.exe mostally available in ( c:\windows\system32).
with regards
Yogesh Agarwal
|
|
|
|
|
There is no such thing as .NET dll registration
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Hi All,
in my project there are the word file stored using the import option, now these file has to be forworded to other people using emails, now i picked the file and attached ti with mail, but i have to send the file using a word template alleady defined.
So if i picked the tamplate then the problem is i am not creating a new file it has to be attched to the existing one & if i try to write the content into that file the format is totally changed for that existing file.
Plz help me to solve this problem
Thanks is advance
Yogesh Agarwal
|
|
|
|
|
When we r cerating setup and run application on network computer of our vb.net appilcation, ther is some problem in crystal report I have alrady using merg module but at the time lodeing of dll message generated " Log on faild coud not lode file or assembaly" please suggest me to solve that problem.
|
|
|
|
|
try to install the .net frame work in the other computer you are using.
Don't block the drive way of all the newbies in programming.
|
|
|
|
|
I want to install .net application on AS/400.
Is there framework avaliable for AS/400 or for other platform
|
|
|
|
|
The only other implimentation of .NET is Mono, for *nix.
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Hi All,
I devlop a software where the report are genrated automatically in excel sheet the problem is when we do this the report will created but when i want to open the file the file will not open due to excel application allready running in background.
I use the application.quit but excel is still running i background, so it has to be closed by user by pressing alt+ctrl+delete.
Plz help me how could i solve this problem
with regards
YOGESH AGARWAL
|
|
|
|
|
I don't see why Excel already having started should be a problem, unless it's created the report and is locking the file ?
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
hi all, i am developing a barcode system of one factory. my client wants to shutdown the computer if he or she click the button log out.
can anyone can give me an idea about that task. all i have to do is, if i click the button Log Out my computer will shutdown. by the way i'm using vb 6.0 in that project. thanks for advance.
Don't block the drive way of all the newbies in programming.
|
|
|
|
|
Hi buddy
use the shell command as following..
Shell "shutdown -s -t 0"
|
|
|
|
|
Hi, Dear
I like the answer, Now plz tell me how could i run this command on click event of a button in VB.Net .
Awaiting for your reply
Yogesh Agarwal
|
|
|
|
|
try the same code as you see. paste it in button in vb.net
Don't block the drive way of all the newbies in programming.
|
|
|
|
|
hey dude thanks for the reply. it works now. thank you.
Don't block the drive way of all the newbies in programming.
|
|
|
|
|
I need Ms Access password Viewer,
will someone help.
|
|
|
|
|
This is a programming forum, do you have a programming question ?
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
|
Is there a way in VB.net to start a program I write when a different program starts. I want my program to run in the back ground and listen to it and do something when it completes a certain task.
|
|
|
|
|
Well you can write a windows service that periodically checks the processes for the application you want to track...
|
|
|
|
|
There's no way to attach your esxecutable to another one. You have to have code either already running and watching the Process list or you have to create a batch file to launch the target .EXE, then launch your .EXE, but using this method it's very easy to stop your code from launching.
|
|
|
|