flat assembler
Message board for the users of flat assembler.

Index > Windows > Don't know where to go?

Author
Thread Post new topic Reply to topic
senolc_eht



Joined: 22 Mar 2004
Posts: 57
Location: Indonesia
senolc_eht 01 Feb 2008, 00:46
If this question is in wrong section please forgive me.

I wan't to make an application to print to usb printer from my old dos application, so i start googling about USB in DOS then I find this site http://www.frontiernet.net/~fys/usb.htm with small modification i can use it with fasm and run it in real dos (even it's long way to do print) and find the usb data (such vendorID and deviceID).

The problem is my customer used my old dos application side by side with windows application (running in dos windows box) and this code doesn't work in dos windows box.

the question is:
is there any way to use int 1Ah in dos under windows (get pci and usb port) ?
or is there any way to get usb port in real dos and dos under windows?

thanks for the advance
regard,

senolc_eht
PS: like the subject i don't know to post about it so post in here.

_________________
sorry if i always asking.....
Post 01 Feb 2008, 00:46
View user's profile Send private message Yahoo Messenger Reply with quote
LocoDelAssembly
Your code has a bug


Joined: 06 May 2005
Posts: 4624
Location: Argentina
LocoDelAssembly 01 Feb 2008, 01:14
But does your program run under Windows (so under NTVDM)? If it is the case what is the problem with printing throught LPT1 port? Last time I've tried under a WinXP it worked (the program was Word Perfect 5.1 and it was set up for an Epson FX 850 even though it was a Canon BJC-4200 because my printer has compatibility with that printer and so the Windows driver).

Check if you USB printer driver allows you to capture LPT1 port, if not I suggest to search for some virtual printer driver that allows that because I think you will have no luck in accessing the USB printer directly and even if you can you would mess the system anyway.
Post 01 Feb 2008, 01:14
View user's profile Send private message Reply with quote
farrier



Joined: 26 Aug 2004
Posts: 274
Location: North Central Mississippi
farrier 01 Feb 2008, 07:10
senolc_eht,

I had to do something similar with a FoxPro for Dos program I am still supporting after 18 years. I had problems in a number of multi-user installations when transferring to Windows XP pro, where sometimes the printer would print and sometimes it wouldn't. From within the Dos program, I could specify a file name instead of LPTx or COMx. The Dos program would open the file--just as it would a printer port--, write the data to be printed, including the control codes, and then close the file as the "printer port" was closed.

What I did to solve the problem was to write a program which runs constantly, and monitors the directory where the files are created, and when the file is created and closed, my program transfers the data to any printer on the network.

If something like this would help, I'll provide the code.

hth,

farrier

_________________
Some Assembly Required
It's a good day to code!
U.S.Constitution; Bill of Rights; Amendment 1:
... the right of the people peaceably to assemble, ...
The code is dark, and full of errors!
Post 01 Feb 2008, 07:10
View user's profile Send private message Reply with quote
DJ Mauretto



Joined: 14 Mar 2007
Posts: 464
Location: Rome,Italy
DJ Mauretto 01 Feb 2008, 12:01
Quote:
is there any way to use int 1Ah in dos under windows (get pci and usb port) ?


Only under Windows 98,but note that you will get only PCI Bus/Device/Function ,then you must scan from offset 0x10 for search Base Address


Quote:
or is there any way to get usb port in real dos and dos under windows?

Sure,in pure Dos,win 98 (and in some case on Xp not update) you can retrieve usb base address trough PCI low level interface 0xcf8 for write in dword ,0xcfc 0xcfd 0xcfe 0xcff for read byte,word dword ,you must scan all device and search for usb class code:wink:
Note further that UHCI is usually in I/O space ,but EHCI is Memory Mapped I/O ,thus you can access only trough pure DOS unreal mode
Search PCI Local Bus specification.
Post 01 Feb 2008, 12:01
View user's profile Send private message Reply with quote
senolc_eht



Joined: 22 Mar 2004
Posts: 57
Location: Indonesia
senolc_eht 02 Feb 2008, 00:26
Quote:

But does your program run under Windows (so under NTVDM)?


yes, except for Vista and sometimes windows ME (running but very slow)

Quote:

Check if you USB printer driver allows you to capture LPT1 port, if not I suggest to search for some virtual printer driver that allows that because I think you will have no luck in accessing the USB printer directly and even if you can you would mess the system anyway


I try to capture LPT1 port with "Net Use" command get error message you can't use in your own computer or something like this, is there any other way to capture lpt port?

and about the Virtual Printer Driver is there any free software? I just can't tell to my customer to buy Virtual Printer Driver that more expensive then my programs.
Quote:

What I did to solve the problem was to write a program which runs constantly, and monitors the directory where the files are created, and when the file is created and closed, my program transfers the data to any printer on the network.

If something like this would help, I'll provide the code.


I would like to see the code, if you allow me.
Quote:

Sure,in pure Dos,win 98 (and in some case on Xp not update) you can retrieve usb base address trough PCI low level interface 0xcf8 for write in dword ,0xcfc 0xcfd 0xcfe 0xcff for read byte,word dword ,you must scan all device and search for usb class code:wink:
Note further that UHCI is usually in I/O space ,but EHCI is Memory Mapped I/O ,thus you can access only trough pure DOS unreal mode
Search PCI Local Bus specification.


thanks for the information i'll learn that interface number.


thanks every body for the help and the respon, if there any other sugestion is accepted.

best Regard,

Senolc_eht
Post 02 Feb 2008, 00:26
View user's profile Send private message Yahoo Messenger Reply with quote
farrier



Joined: 26 Aug 2004
Posts: 274
Location: North Central Mississippi
farrier 02 Feb 2008, 07:12
senolc_eht,

The attached source code is in MASM syntax, messy, and all I have access to this weekend!

How it works:

The program starts and is not displayed; invoke ShowWindow, hWnd, SW_HIDE
Any left over remnants of the "print files" are deleted in case they remained after a previous termination
A thread is created to handle all chores
Within the thread, FindFirstChangeNotification is invoked with FILE_NOTIFY_CHANGE_FILE_NAME as the dwNotifyFilter. This will "notify" us of any file creation.

WaitForSingleObject will wait for a notification.

Within a never ending while loop, we are "notified" and check for the existence of the "print file" we are interested in, using OpenFile with OF_EXIST flag. If detected, we run the print routine.

Within the print routine, CreateFile is used to open the file in question exclusively, this may fail if the file is still open during the Dos programs file creation process. Once the Dos program has finished the creation process, the file is closed, and we are able to open the file exclusively.

The contents of the "print file" is read and stored, then the "print file" is deleted so as not to interfere with the Dos program creating another "print file".

The rest of the print routine is derived from http://support.microsoft.com/kb/138594/ to
OpenPrinter
StartDocPrinter
StartPagePrinter
WritePrinter
EndPagePrinter
EndDocPrinter
ClosePrinter

Then FindNextChangeNotification
And WaitForSingleObject
And loop forever

About this source code: There were as many as 5 different printers, printing different forms. That is why it checks for all of the file names. Also, the program had to run on Win95 thru NT and beyond, so there are two different dll's used for print spooling. This is checked for at startup, and LoadLibrary is used to determine the address of the above print functions depending on the dll in use.

hth,

farrier


Description:
Download
Filename: NotifyPrint.zip
Filesize: 7.27 KB
Downloaded: 308 Time(s)


_________________
Some Assembly Required
It's a good day to code!
U.S.Constitution; Bill of Rights; Amendment 1:
... the right of the people peaceably to assemble, ...
The code is dark, and full of errors!
Post 02 Feb 2008, 07:12
View user's profile Send private message Reply with quote
senolc_eht



Joined: 22 Mar 2004
Posts: 57
Location: Indonesia
senolc_eht 04 Feb 2008, 00:19
farrier,


thanks for sharing the code, this will help much for me

best regard,

Senolc_eht
Post 04 Feb 2008, 00:19
View user's profile Send private message Yahoo Messenger Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.