|
What is the problem that your having with the code? What are the errors? The code will work with Win98, but it may take a little modification to do so.
For instance, since Unicode support on anything other than an NT/2000/XP/2003 is questionable, you can have DLLImport hunt down the correct version of the imported functions without you having to guess at which version is available by making the following changes:
* Make sure that the EntryPoint names DON'T end in W or A.
* Change the CharSet option to CharSet.Auto.
* Change the ExactSpelling option to False.
You might want to start with this:
<DllImport("winspool.Drv", EntryPoint:="OpenPrinter", _
SetLastError:=True, CharSet:=CharSet.Auto, _
ExactSpelling:=False, CallingConvention:=CallingConvention.StdCall)> _
Public Shared Function OpenPrinter(ByVal src As String, ByRef hPrinter As IntPtr, ByVal pd As Long) As Boolean
End Function
<DllImport("winspool.Drv", EntryPoint:="ClosePrinter", _
SetLastError:=True, CharSet:=CharSet.Auto, _
ExactSpelling:=False, CallingConvention:=CallingConvention.StdCall)> _
Public Shared Function ClosePrinter(ByVal hPrinter As IntPtr) As Boolean
End Function
<DllImport("winspool.Drv", EntryPoint:="StartDocPrinter", _
SetLastError:=True, CharSet:=CharSet.Auto, _
ExactSpelling:=False, CallingConvention:=CallingConvention.StdCall)> _
Public Shared Function StartDocPrinter(ByVal hPrinter As IntPtr, _
ByVal level As Int32, ByRef pDI As DOCINFOW) As Boolean
End Function
<DllImport("winspool.Drv", EntryPoint:="EndDocPrinter", _
SetLastError:=True, CharSet:=CharSet.Auto, _
ExactSpelling:=False, CallingConvention:=CallingConvention.StdCall)> _
Public Shared Function EndDocPrinter(ByVal hPrinter As IntPtr) As Boolean
End Function
<DllImport("winspool.Drv", EntryPoint:="StartPagePrinter", _
SetLastError:=True, CharSet:=CharSet.Auto, _
ExactSpelling:=False, CallingConvention:=CallingConvention.StdCall)> _
Public Shared Function StartPagePrinter(ByVal hPrinter As IntPtr) As Boolean
End Function
<DllImport("winspool.Drv", EntryPoint:="EndPagePrinter", _
SetLastError:=True, CharSet:=CharSet.Auto, _
ExactSpelling:=False, CallingConvention:=CallingConvention.StdCall)> _
Public Shared Function EndPagePrinter(ByVal hPrinter As IntPtr) As Boolean
End Function
<DllImport("winspool.Drv", EntryPoint:="WritePrinter", _
SetLastError:=True, CharSet:=CharSet.Auto, _
ExactSpelling:=False, CallingConvention:=CallingConvention.StdCall)> _
Public Shared Function WritePrinter(ByVal hPrinter As IntPtr, _
ByVal pBytes As IntPtr, ByVal dwCount As Int32, ByRef dwWritten As Int32) As Boolean
End Function
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
I get no error. It just does not print. Do you have any knowledge about printers wide mode (136 columns)?
|
|
|
|
|
It's been a VERY long time since I played with a dot matrix printer, but yes I do know how the command set for them works.
Have you tried the modifications to the code that I posted?
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
I had no time to try your modification because of other deadlines. I will try it out. Thanks a lot.
|
|
|
|
|
You may not get a solution for Every Printer out there, I just tried that code(322090 HOW TO) on a win98se and a OKIData Microline 321 (with OKI Drivers) and it worked just fine.
Not all Dot Matrix printers follow the same Specifications and Standards.
|
|
|
|
|
Hi all, a rather basic question but...
Is it possible to create a VB.NET application that does not need the 20MB++ .NET framework installed when I distribute the program (need suport for 98, xp, nt and 2000)???
I have done some winodows programming before in VS6 and then you only needed the vbrundll files that are much smaller, I can accept to install them with my application but when the application is a small serial tool < 1MB in size I would rather not need to install 20MB++ of suport files. This might also scare the customers a bit with reboots and all.
If the answer is now, are there any other solution???
There are a lot of programs on the net and I have never seen any "small application" instalation files big enough to include the .NET framwork instalation, how do they solve the problem.
One option would be to use VB6 but Im about to start at a new company and need to get a new dev enviroment and I dont thik you can buy that anymore? It also feels a bit bad to start something new with buying old tools...
If the answer to all the questions is no, is the only solution to create a small standalone windows application to use VC++???
regards Me
|
|
|
|
|
Code written in VB.NET does not compile to machine code. Instead, intermediate language (MSIL) code is produced, which then needs to be Just-In-Time compiled in order to run. No runtime = no run.
There is a app called Thinstall [^] that is supposedly is able to compile your app along with whatever parts of the .NET framework you use into an executable that can run with the framework installed on the target machine, but I've never used it or spoken with anyone who has.
Also, the 23MB install for the framework is a one-shot deal (assuming you stick with one version of it), so you won't need to reinstall it with every app you distribute.
Using .NET can pay big dividends when it comes to developer productivity, though, so it's not exactly apples to apples when comparing runtime size. There are certainly other factors involved.
Charlie
if(!curlies){ return; }
|
|
|
|
|
aslm wrote:
There are a lot of programs on the net and I have never seen any "small application" instalation files big enough to include the .NET framwork instalation, how do they solve the problem.
Most applications you pickup off the 'Net are not written in VB.NET. If you do, then most will not come with the .NET Framework installation. They'll assume you have the correct version of the .NET Framework installed already.
Besides, a 23MB file being downloaded off the 'Net is nothing nowadays.
Also, if you concerned with future developement, keep in mind that every new version of Windows will now come with the latest .NET Framework as part of the OS. Windows Server 2003 comes with .NET Framework 1.1 already installed.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
How do i convert the following into a fully multithreaded tcp server and remove the two addhandler(linerecieved,ondisconnected), i just know how
to remove the addhandler and make it into a separate thread.
any help would be appreciated.
thanks
jim
[UI form]
Option Strict On
Imports System.Threading
Imports System.Net.Sockets
Imports System.Net
Private myThread as thread
private mysocket as Tcplistener
Private Sub clsServer_load(...)
mythread = New threading.thread(addressof Dolisten)
mythread.start()
end sub
Pirvate dolisten()
dim localaddr = system.net.ipaddress
try
mysocket = new Tcplistener(localaddr,1234)
mysocket.start()
do
dim x as New clsClient(mysocket.AcceptTcpClient)
AddHandler x.Disconnected, AddressOf onDisconnected
AddHandler x.myReceived, AddressOf LineReceived
mcolClients.Add(x.ID, x)
Loop Until False
catch
end try
end sub
Public Sub LineReceived(ByVal sender As clsClient, ByVal strString As String)
'process recive data here
end sub
[clsClient.vb]
Option Strict On
Imports System.Net.Sockets
Imports System.Text
'client class to handle the new client connected to the server
Public Class clsClient
Public Event Disconnected(ByVal sender As clsClient)
Public Event LineReceived(ByVal sender As clsClient, ByVal Data As String)
Private mgID As Guid = Guid.NewGuid
Const BUFFER_SIZE As Integer = 512
Private mobjClient As TcpClient
Private marData(BUFFER_SIZE) As Byte
Private mobjText As New StringBuilder()
Public ReadOnly Property ID() As String
Get
Return mgID.ToString
End Get
End Property
Public Sub New(ByVal client As TcpClient)
mobjClient = client
mobjClient.GetStream.BeginRead(marData, 0, BUFFER_SIZE, AddressOf DoStreamReceive, Nothing)
End Sub
Private Sub DoStreamReceive(ByVal ar As IAsyncResult)
Dim intCount As Integer
Dim clientdata As String = Encoding.ASCII.GetString(marData)
Try
SyncLock mobjClient.GetStream
intCount = mobjClient.GetStream.EndRead(ar)
End SyncLock
If intCount < 1 Then
RaiseEvent Disconnected(Me)
Exit Sub
End If
RaiseEvent LineReceived(Me, clientdata)
SyncLock mobjClient.GetStream
mobjClient.GetStream.BeginRead(marData, 0, BUFFER_SIZE, AddressOf DoStreamReceive, Nothing)
End SyncLock
Catch ex As Exception
RaiseEvent Disconnected(Me)
End Try
End Sub
Public Sub Send(ByVal Data As String)
SyncLock mobjClient.GetStream
Dim w As New IO.StreamWriter(mobjClient.GetStream)
w.Write(Data)
w.Flush()
End SyncLock
End Sub
End Class
-just make it tough
|
|
|
|
|
http://www.planet-source-code.com/vb/scripts/ShowCode.asp?txtCodeId=331&lngWId=10
Multi-Threaded TCP Chat Example
This is an example of how to implement the System.Sockets and System.Threading classes in VB.Net. It includes a multi-threaded server application as well as a client to demomstrate its use. This code is based off of a code example written in C# by Nick Ruisi on PSC, so give credit where credit is due. Enjoy!
|
|
|
|
|
im not saying that its mine, that is why im needing your help, who knows that code also was taken from other authors too aside from the author who posted on PSC
so i would give credit to those who made the .NET Team, not just the author who posted it on PSC
do you think if i made that code i would still be asking you?
peace!
jim
-just make it tough
|
|
|
|
|
jimmypearly,
Hey jim, that quote was just pasted in from the page link I sent you, It's on that page as a description. I didn't write it.
I don't think it was intended to be offensive, especialy by me.
Sorry.
|
|
|
|
|
I need to write a macro app. This is why I need to know how can I immitate clicking somewhere in the window of other app. Thanks for answers.
|
|
|
|
|
|
For example: There's an foreign app, in its form is a button or other control... I want to build an app, which allowes me to generate the click programmaticaly, without using a mouse.
|
|
|
|
|
You could generate the mouse click, but how are you going to guarantee that the window your "clicking" on is going to be in the exact same place every time it comes up?
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
It's maximized window all the time. But how can I do it?
|
|
|
|
|
I gave you a hint at what the pitfalls are...
But, it's not as easy as it would sound. You have to define the structures that define the type and specifics of the input your sending, namely mouse clicks, and use the SendInput Win32 API function to post the message for you.
See SendInput on P/Invoke.net[^] for an example and some docs. Make SURE you follow and read the links for defining the INPUT, MOUSEINPUT, KEYBOARDINPUT, HARDWAREINPUT, and VK structures!
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Thanks a lot. I will look at it and I will try it tommorow. So please, look back at this thread tommorow this time, I will let you know how I solved it. Now I go to bed It's about midnight.
|
|
|
|
|
You can use these api functions to simulate a button click
Declare these at the top of your class/ form/ module
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Declare Function FindWindowEx Lib "user32" Alias "FindWindowExA" (ByVal hWnd1 As Long, ByVal hWnd2 As Long, ByVal lpsz1 As String, ByVal lpsz2 As String) As Long
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Const BM_CLICK = &HF5
I used another command button to click ok on a message box.
If you investigtate the findwindow function, the second param can be the name of the window to find (at present it is the Msgbox class id but you can place vbnullstring there and place the window name in the place of vbnullstring)
Private Sub Command1_Click()
Dim x As Long, staticx As Long, MyStr As String, y As String, control As Long
'Find the window you specify
x = FindWindow("#32770", vbNullString)
' get handle to Ok button
control = FindWindowEx(x, 0, "Button", "Ok")
' click the button
SendMessage control, BM_CLICK, 0, 0
SendMessage control, BM_CLICK, 0, 0
End Sub
For some reason you need to send the message twice. I think it is because the first just selects it.
Enjoy
"I am what i am, and i do what i do, but sometimes i do, what you want me to do."
|
|
|
|
|
I am afraid this code doesn't work for me ( What's your operating system -I have WXPP, VS.NET.
|
|
|
|
|
I've just found out why it doesn't work - MSDN - This function was superseeded for WXP and W2k
|
|
|
|
|
The reason is possibly because this is vb6 code.
I have Windows XP and it works fine, did you want it for vb.net then?
Sorry mate
|
|
|
|
|
I want to do the way Favorite of IE, while high light on a favorite, you can
right click to rename or delete a favorite menuitem. Expert, how can I do
this, thank you!
|
|
|
|
|
Do what? Create your own context menu? Add an item to IE's context menu? Add an item to the shell context menu?
All you did was describe right-clicking on an item in IE's Favorites menu and renaming it. You haven't said anything about what you want to do.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|