Hi everyone
I am facing a strange problem in the exe file of my project. i.e
I created setup for software instllation. I tried it on my PC and works fine. However, when my supervisor run it on his laptop i.e connected to a wireless network; and a printer is attached in the network. He complains that:
he is not able to Save a transaction and Print it on his laptop.(When I save a transection it prints a ticket and then save it). When he Reprint Last Ticket(last performed transection) it generates a MDI file and opens Microsift Office Document Imaging.
p.s.Currently I m working on a standalone computer with a dedicated printer attached to it.
I am not able ti understand what the problem is. As its working on my pc and save a transection. I hope I'll get a useful information to resolve thid problem.
Farhana
7 1553
It could just be a matter of what he has set up as his default printer.
QVeen72 1,445
Recognized Expert Top Contributor
Hi,
Why don't you try installing a new printer in your client's system?
Maybe his default printer is configured to print to a file.
Regards
Veena
...when my supervisor run it on his laptop i.e connected to a wireless network; and a printer is attached in the network. He complains that:
he is not able to Save a transaction and Print it on his laptop...
Hi ,
Make sure that if you are using any .dll file or other then it should be in the same folder in which you have saved the VB project. Make changes in the code like if you give the path as "\\server\abc\d ddd\mm.bmp" then just change it to "mm.bmp".
I was facing same type of problem as you are facing but after that solution my problem is solved out.
Mayur
Hello guys thanks for your help
Problem is solved and ticket can be printed and transection is saved successfully into the machine.
What I did?
I used default printer attached to the PC to print ticket, before this I had mentioned which printer to use to print the ticket. I think my client and I didn't have same printers.
But this is not what I want to do. Actually I want to select a printer at runtime because I want to print tickets on ticket printer and reports on another printer
Any clues?? please
thanks in advance
Farhana
hi
following is the code to set default printer
open a new standard exe project
add a moudle
on the form1 draw a command button and name it cmdSetDef
add a listbox List1
copy and paste following code in the Form1 code window -
Private Function PtrCtoVbString(Add As Long) As String
-
-
Dim sTemp As String * 512, x As Long
-
-
x = lstrcpy(sTemp, Add)
-
If (InStr(1, sTemp, Chr(0)) = 0) Then
-
PtrCtoVbString = ""
-
Else
-
PtrCtoVbString = Left(sTemp, InStr(1, sTemp, Chr(0)) - 1)
-
End If
-
End Function
-
-
Private Sub Win95SetDefaultPrinter()
-
Dim Handle As Long 'handle to printer
-
Dim PrinterName As String
-
Dim pd As PRINTER_DEFAULTS
-
Dim x As Long
-
Dim need As Long ' bytes needed
-
Dim pi5 As PRINTER_INFO_5 ' your PRINTER_INFO structure
-
Dim LastError As Long
-
-
' determine which printer was selected
-
PrinterName = List1.List(List1.ListIndex)
-
' none - exit
-
If PrinterName = "" Then
-
Exit Sub
-
End If
-
-
' set the PRINTER_DEFAULTS members
-
pd.pDatatype = 0&
-
pd.DesiredAccess = PRINTER_ALL_ACCESS
-
-
' Get a handle to the printer
-
x = OpenPrinter(PrinterName, Handle, pd)
-
' failed the open
-
If x = False Then
-
'error handler code goes here
-
Exit Sub
-
End If
-
-
' Make an initial call to GetPrinter, requesting Level 5
-
' (PRINTER_INFO_5) information, to determine how many bytes
-
' you need
-
x = GetPrinter(Handle, 5, ByVal 0&, 0, need)
-
' don't want to check GetLastError here - it's supposed to fail
-
' with a 122 - ERROR_INSUFFICIENT_BUFFER
-
' redim t as large as you need
-
ReDim t((need \ 4)) As Long
-
-
' and call GetPrinter for keepers this time
-
x = GetPrinter(Handle, 5, t(0), need, need)
-
' failed the GetPrinter
-
If x = False Then
-
'error handler code goes here
-
Exit Sub
-
End If
-
-
' set the members of the pi5 structure for use with SetPrinter.
-
' PtrCtoVbString copies the memory pointed at by the two string
-
' pointers contained in the t() array into a Visual Basic string.
-
' The other three elements are just DWORDS (long integers) and
-
' don't require any conversion
-
pi5.pPrinterName = PtrCtoVbString(t(0))
-
pi5.pPortName = PtrCtoVbString(t(1))
-
pi5.Attributes = t(2)
-
pi5.DeviceNotSelectedTimeout = t(3)
-
pi5.TransmissionRetryTimeout = t(4)
-
-
' this is the critical flag that makes it the default printer
-
pi5.Attributes = PRINTER_ATTRIBUTE_DEFAULT
-
-
' call SetPrinter to set it
-
x = SetPrinter(Handle, 5, pi5, 0)
-
' failed the SetPrinter
-
If x = False Then
-
MsgBox "SetPrinterFailed. Error code: " & GetLastError()
-
Exit Sub
-
End If
-
-
' and close the handle
-
ClosePrinter (Handle)
-
-
End Sub
-
Private Sub GetDriverAndPort(ByVal Buffer As String, DriverName As String, PrinterPort As String)
-
Dim iDriver As Integer
-
Dim iPort As Integer
-
DriverName = ""
-
PrinterPort = ""
-
-
'The driver name is first in the string terminated by a comma
-
iDriver = InStr(Buffer, ",")
-
If iDriver > 0 Then
-
-
'Strip out the driver name
-
DriverName = Left(Buffer, iDriver - 1)
-
-
'The port name is the second entry after the driver name
-
'separated by commas.
-
iPort = InStr(iDriver + 1, Buffer, ",")
-
-
If iPort > 0 Then
-
'Strip out the port name
-
PrinterPort = Mid(Buffer, iDriver + 1, _
-
iPort - iDriver - 1)
-
End If
-
End If
-
End Sub
-
-
Private Sub ParseList(lstCtl As Control, ByVal Buffer As String)
-
Dim i As Integer
-
-
Dim s As String
-
-
Do
-
i = InStr(Buffer, Chr(0))
-
If i > 0 Then
-
s = Left(Buffer, i - 1)
-
If Len(Trim(s)) Then lstCtl.AddItem s
-
Buffer = Mid(Buffer, i + 1)
-
Else
-
If Len(Trim(Buffer)) Then lstCtl.AddItem Buffer
-
Buffer = ""
-
End If
-
Loop While i > 0
-
End Sub
-
-
Private Sub WinNTSetDefaultPrinter()
-
Dim Buffer As String
-
Dim DeviceName As String
-
Dim DriverName As String
-
Dim PrinterPort As String
-
Dim PrinterName As String
-
Dim r As Long
-
If List1.ListIndex > -1 Then
-
'Get the printer information for the currently selected
-
'printer in the list. The information is taken from the
-
'WIN.INI file.
-
Buffer = Space(1024)
-
PrinterName = List1.Text
-
r = GetProfileString("PrinterPorts", PrinterName, "", _
-
Buffer, Len(Buffer))
-
-
'Parse the driver name and port name out of the buffer
-
GetDriverAndPort Buffer, DriverName, PrinterPort
-
-
If DriverName <> "" And PrinterPort <> "" Then
-
SetDefaultPrinter List1.Text, DriverName, PrinterPort
-
End If
-
End If
-
End Sub
-
-
Private Sub SetDefaultPrinter(ByVal PrinterName As String, _
-
ByVal DriverName As String, ByVal PrinterPort As String)
-
Dim DeviceLine As String
-
Dim r As Long
-
Dim l As Long
-
DeviceLine = PrinterName & "," & DriverName & "," & PrinterPort
-
' Store the new printer information in the [WINDOWS] section of
-
' the WIN.INI file for the DEVICE= item
-
r = WriteProfileString("windows", "Device", DeviceLine)
-
' Cause all applications to reload the INI file:
-
l = SendMessage(HWND_BROADCAST, WM_WININICHANGE, 0, "windows")
-
End Sub
-
-
-
Private Sub cmdSetDef_Click()
-
Dim osinfo As OSVERSIONINFO
-
Dim retvalue As Integer
-
-
osinfo.dwOSVersionInfoSize = 148
-
osinfo.szCSDVersion = Space$(128)
-
retvalue = GetVersionExA(osinfo)
-
-
If osinfo.dwMajorVersion = 3 And osinfo.dwMinorVersion = 51 And _
-
osinfo.dwBuildNumber = 1057 And osinfo.dwPlatformId = 2 Then
-
Call WinNTSetDefaultPrinter
-
ElseIf osinfo.dwMajorVersion = 4 And osinfo.dwMinorVersion = 0 _
-
And osinfo.dwBuildNumber >= 67109814 And osinfo.dwPlatformId = 1 Then
-
Call Win95SetDefaultPrinter
-
ElseIf osinfo.dwMajorVersion = 4 And osinfo.dwMinorVersion = 0 _
-
And osinfo.dwBuildNumber = 1381 And osinfo.dwPlatformId = 2 Then
-
Call WinNTSetDefaultPrinter
-
End If
-
-
End Sub
-
-
Private Sub Form_Load()
-
Dim r As Long
-
Dim Buffer As String
-
-
'Get the list of available printers from WIN.INI
-
Buffer = Space(8192)
-
r = GetProfileString("PrinterPorts", vbNullString, "", _
-
Buffer, Len(Buffer))
-
-
'Display the list of printer in the list box List1
-
ParseList List1, Buffer
-
End Sub
-
*************** *********
paste following code in the Module1 -
Public Const WM_WININICHANGE = &H1A
-
-
' constants for DEVMODE structure
-
Public Const CCHDEVICENAME = 32
-
Public Const CCHFORMNAME = 32
-
-
' constants for DesiredAccess member of PRINTER_DEFAULTS
-
Public Const STANDARD_RIGHTS_REQUIRED = &HF0000
-
Public Const PRINTER_ACCESS_ADMINISTER = &H4
-
Public Const PRINTER_ACCESS_USE = &H8
-
Public Const PRINTER_ALL_ACCESS = (STANDARD_RIGHTS_REQUIRED Or PRINTER_ACCESS_ADMINISTER Or PRINTER_ACCESS_USE)
-
-
' constant that goes into PRINTER_INFO_5 Attributes member
-
' to set it as default
-
Public Const PRINTER_ATTRIBUTE_DEFAULT = 4
-
-
Public Type OSVERSIONINFO
-
dwOSVersionInfoSize As Long
-
dwMajorVersion As Long
-
dwMinorVersion As Long
-
dwBuildNumber As Long
-
dwPlatformId As Long
-
szCSDVersion As String * 128
-
End Type
-
-
Type ACL
-
AclRevision As Byte
-
Sbz1 As Byte
-
AclSize As Integer
-
AceCount As Integer
-
Sbz2 As Integer
-
End Type
-
-
-
Type SECURITY_DESCRIPTOR
-
Revision As Byte
-
Sbz1 As Byte
-
Control As Long
-
Owner As Long
-
Group As Long
-
Sacl As ACL
-
Dacl As ACL
-
End Type
-
-
-
Public Type DEVMODE
-
dmDeviceName As String * CCHDEVICENAME
-
dmSpecVersion As Integer
-
dmDriverVersion As Integer
-
dmSize As Integer
-
dmDriverExtra As Integer
-
dmFields As Long
-
dmOrientation As Integer
-
dmPaperSize As Integer
-
dmPaperLength As Integer
-
dmPaperWidth As Integer
-
dmScale As Integer
-
dmCopies As Integer
-
dmDefaultSource As Integer
-
dmPrintQuality As Integer
-
dmColor As Integer
-
dmDuplex As Integer
-
dmYResolution As Integer
-
dmTTOption As Integer
-
dmCollate As Integer
-
dmFormName As String * CCHFORMNAME
-
dmLogPixels As Integer
-
dmBitsPerPel As Long
-
dmPelsWidth As Long
-
dmPelsHeight As Long
-
dmDisplayFlags As Long
-
dmDisplayFrequency As Long
-
dmICMMethod As Long ' // Windows 95 only
-
dmICMIntent As Long ' // Windows 95 only
-
dmMediaType As Long ' // Windows 95 only
-
dmDitherType As Long ' // Windows 95 only
-
dmReserved1 As Long ' // Windows 95 only
-
dmReserved2 As Long ' // Windows 95 only
-
End Type
-
-
Type PRINTER_INFO_2
-
pServerName As String
-
pPrinterName As String
-
pShareName As String
-
pPortName As String
-
pDriverName As String
-
pComment As String
-
pLocation As String
-
pDevMode As DEVMODE
-
pSepFile As String
-
pPrintProcessor As String
-
pDatatype As String
-
pParameters As String
-
pSecurityDescriptor As SECURITY_DESCRIPTOR
-
Attributes As Long
-
Priority As Long
-
DefaultPriority As Long
-
StartTime As Long
-
UntilTime As Long
-
Status As Long
-
cJobs As Long
-
AveragePPM As Long
-
End Type
-
-
-
Public Type PRINTER_INFO_5
-
pPrinterName As String
-
pPortName As String
-
Attributes As Long
-
DeviceNotSelectedTimeout As Long
-
TransmissionRetryTimeout As Long
-
End Type
-
-
Public Type PRINTER_DEFAULTS
-
pDatatype As Long
-
pDevMode As DEVMODE
-
DesiredAccess As Long
-
End Type
-
-
Declare Function GetProfileString Lib "kernel32" Alias "GetProfileStringA" (ByVal lpAppName As String, ByVal lpKeyName As String, ByVal lpDefault As String, ByVal lpReturnedString As String, ByVal nSize As Long) As Long
-
Declare Function WriteProfileString Lib "kernel32" Alias "WriteProfileStringA" (ByVal lpszSection As String, ByVal lpszKeyName As String, ByVal lpszString As String) As Long
-
Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lparam As String) As Long
-
Declare Function GetVersionExA Lib "kernel32" (lpVersionInformation As OSVERSIONINFO) As Integer
-
Public Declare Function OpenPrinter Lib "winspool.drv" Alias "OpenPrinterA" (ByVal pPrinterName As String, phPrinter As Long, pDefault As PRINTER_DEFAULTS) As Long
-
Public Declare Function SetPrinter Lib "winspool.drv" Alias "SetPrinterA" (ByVal hPrinter As Long, ByVal Level As Long, pPrinter As Any, ByVal Command As Long) As Long
-
Public Declare Function GetPrinter Lib "winspool.drv" Alias "GetPrinterA" (ByVal hPrinter As Long, ByVal Level As Long, pPrinter As Any, ByVal cbBuf As Long, pcbNeeded As Long) As Long
-
Public Declare Function lstrcpy Lib "kernel32" Alias "lstrcpyA" (ByVal lpString1 As String, ByVal lpString2 As Any) As Long
-
Public Declare Function ClosePrinter Lib "winspool.drv" (ByVal hPrinter As Long) As Long
-
Public Declare Function GetLastError Lib "kernel32" () As Long
-
regards
manpreet singh dhillon hoshiarpur
QVeen72 1,445
Recognized Expert Top Contributor
Hi,
First Re-Name the Ticket Printer as TicketPrinter, and Another Default Printer as DefPrinter.
write this Code in .bas Module: -
Public Declare Function WriteProfileString Lib "kernel32" Alias "WriteProfileStringA" (ByVal lpszSection As String, ByVal lpszKeyName As String, ByVal lpszString As String) As Long
-
-
Public Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
-
-
Public Const HWND_BROADCAST = &HFFFF&
-
Public Const WM_WININICHANGE = &H1A
-
-
Public Function SetDefaultPrinter(objPrn As Printer) As Boolean
-
Dim X As Long, sztemp As String
-
sztemp = objPrn.DeviceName & "," & objPrn.DriverName & "," & objPrn.Port
-
X = WriteProfileString("windows", "device", sztemp)
-
X = SendMessage(HWND_BROADCAST, WM_WININICHANGE, 0&, "windows")
-
End Function
-
From VB call this To Select the Printer:
Ticket : -
SetDefaultPrinter "TicketPrinter"
-
Default: -
SetDefaultPrinter "DefPrinter"
-
REgards
Veena
Thanks guys
I'll try this code.
farhana
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Daniel Moree |
last post by:
I'm using MS VC++ 6.0
I'm working on a big project. I've currently have several files for this
project.
Here's the problem.
I have one header file phead.h
I have two code files main.cpp and gameloop.cpp
phead.h has all my core declarations in it like my main globals.
main.cpp has all my window initilization functions and my winproc loop.
|
by: Dan Smith |
last post by:
When I try to create a new C# Web Reference in Visual Studio 2003, I get an
error message "The proxy settings on this computer are not configured
correctly for web discovery. ..." This web reference is to a service on my
machine - http://localhost/... - so I don't know why any proxy configuration
should be necessary.
Doing the same thing in Visual Studio 2002 works fine (i.e., no error about
"proxy settings"). However, when I update...
|
by: Ditlef |
last post by:
We have a large C++ COM-based project we will migrate (slowly) to .NET.
We have several basic libraries we need to wrap with C++ managed wrapper
libraries. Having C++ runtime Debug/Release mixed with managed code seems to
make problems for project setup.
The document: Team Development with Visual Studio .NET and Visual SourceSafe
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnbda/html/tdlg_ch5.asp
contains...
|
by: spam |
last post by:
Sorry if this is the wrong group but I can't find one on the IDE. I am
finding lots and lots of problems with it and I'm surprised I cannot
find anyone else with the same problems. I'm using 2003 BTW.
The problem that I have at the moment is I have created my own control
by inheriting from ComboBox and this resides in a project. In another
project (but in the same solution) I have been using this control with
no problems. The projects...
|
by: JM |
last post by:
Hi,
I am an old programmer who is only just getting back into it after about 10
years, and for the life of me I can not work out what I am doing wrong.
Firstly, I've recently downloaded and installed the very latest version of
VB.NET Express & SQL Express.
I have been slowly going through the suggested tutorial files on MSDN which
after from the learnvisualstudio.net web site :
| |
by: Richard J Foster |
last post by:
Hi there,
I have a pair of C# projects in VS2003. The first project, a dll, is
referenced in the second via a project reference.
The assemblies in question are delay-signed during a "production" build
process, but not as part of a normal development build.
I have noticed that while the correctly signed assembly is present in
the designated output folder for the project (e.g. bin/Release), an
| |
by: drawing in aspnet |
last post by:
Question about putting the data layer in a separate class library.
I keep reading that the data layer should be separated from the
presentation layer and put in its own class library. I am trying to
do this but running into a problem. I'm hoping someone can point me
in the right direction. I first create a class library (all code in
C#) and within this class library create a very simple Sql Server
Express database (.mdb) file. It's...
|
by: =?Utf-8?B?VG9kZCBEb2JtZXllcg==?= |
last post by:
I am working on developing a program using Visual Studio 2003 but am having
problems getting my program to find my GL.h and GLU.h, and I am guessing it
will have the same problems trying to link to the .lib and .dll files. What
do I all need to do to get this to properly compile and link. Here is what I
have done so far.
Inside my main project directory, I added a folder called "OpenGL" and
inside this folder are 3 sub-folders,...
|
by: Simon |
last post by:
I have problem with namespaces. I have a program that consumes the web
service and has for instance names space nsProgram. In this program I have
defined several classes that I use for storing and handling internal
information. Than I have web service, that also uses the same classes (I
included the file as linked external resource). I included this web service
as web reference and used name wsWeb.
When I am trying to call the web...
|
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 synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
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 captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
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 launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
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 instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |