![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
|
|
#1 |
|
Programmer
Join Date: Nov 2005
Location: Turkey
Posts: 93
Rep Power: 4
![]() |
I can't use my usb printer to print any data
Hi.. I have to learn how to print "hello world " to a paper.. but examples which I found works with dialog box .. I have to make a dos program.. please help me!
thanx. |
|
|
|
|
|
#2 |
|
Hobbyist Programmer
Join Date: Mar 2005
Location: United States
Posts: 124
Rep Power: 4
![]() |
Not sure if there is an easier way, but you could write the text to a file and print the file.
system("print path-to-printer path-to-file");
// example for a default network printer
system("print /d:\\\\server1\\printer1 C:\\helloworld.txt");-BB98
__________________
Learning to use C++ and loving every minute of it. |
|
|
|
|
|
#3 |
|
Resident Grouch
![]() ![]() ![]() ![]() ![]() ![]() Join Date: Jun 2005
Posts: 6,453
Rep Power: 10
![]() |
By 'dos', do you mean a console/command-line program?
__________________
Abstraction doesn't make it impossible to write bad code; it makes it possible to write superior code. Contributor's Corner: Grumpy on C++ Exceptions DaWei on Pointers |
|
|
|
|
|
#4 |
|
Programmer
Join Date: Nov 2005
Location: Turkey
Posts: 93
Rep Power: 4
![]() |
yes.. I tried to tell command-line program...
they don't work . ![]() #include<iostream> main() {system("print path-to-printer path-to-file"); // example for a default network printer system("print /d:\\\\server1\\printer1 C:\\helloworld.txt"); } I'm using visual 2003 what can I do?? |
|
|
|
|
|
#5 |
|
Expert Programmer
Join Date: Aug 2005
Location: Rotterdam, the Netherlands
Posts: 942
Rep Power: 4
![]() |
* Sigh *
Never copy/paste code. Understand its meaning, look at it again, digest it, and you will see what you're doing wrong. |
|
|
|
|
|
#6 |
|
Programming Guru
![]() Join Date: Jun 2005
Location: elemental plane
Posts: 1,429
Rep Power: 5
![]() |
Also please post in code tags. Read the "How to post a question" thread at the top of the forum.
__________________
"Employ your time in improving yourself by other men's writings, so that you shall gain easily what others have labored hard for." -- Socrates |
|
|
|
|
|
#7 |
|
Resident Grouch
![]() ![]() ![]() ![]() ![]() ![]() Join Date: Jun 2005
Posts: 6,453
Rep Power: 10
![]() |
I am going to copy and paste pseudo-code, no matter what you say. When it doesn't woik, I'm going to sue your ass off. Rejoice. You will wind up with my money and I'll wind up buying scotch for my lawyers, to no avail.
__________________
Abstraction doesn't make it impossible to write bad code; it makes it possible to write superior code. Contributor's Corner: Grumpy on C++ Exceptions DaWei on Pointers |
|
|
|
|
|
#8 |
|
Programmer
Join Date: Nov 2005
Location: Turkey
Posts: 93
Rep Power: 4
![]() |
I could do this..
#include <windows.h>
HDC hDC;
SIZE Size;
int y;
void YaziciAc()
{
PRINTDLG pd;
DOCINFO di;
memset(&pd, 0, sizeof(pd));
pd.lStructSize = sizeof(pd);
pd.Flags = PD_RETURNDC | PD_RETURNDEFAULT;
memset( &di, 0, sizeof(di));
di.cbSize = sizeof(di);
di.lpszDocName = "My Document";
PrintDlg(&pd);
hDC = pd.hDC;
StartDoc(pd.hDC, &di);
GetTextExtentPoint32(pd.hDC, "A", 1, &Size);
y = 0;
}
void Yazdir(LPCTSTR yazi)
{
if (y==0)
{
EndPage(hDC);
StartPage(hDC);
}
TextOut(hDC,0, y, yazi, strlen(yazi));
y += Size.cy;
}
void YaziciKapat()
{
EndPage(hDC);
EndDoc(hDC);
DeleteDC(hDC);
}
int main(int argc, char* argv[])
{
YaziciAc();
Yazdir("SATIR 1");
Yazdir("SATIR 2");
/* Yeni sayfa */
y = 0;
Yazdir("SATIR 3");
Yazdir("SATIR 4");
YaziciKapat();
return 0;
} |
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|