?
Solved

Windows DDK Print Sample Code

Posted on 2003-03-28
15
Medium Priority
?
3,234 Views
Last Modified: 2013-12-03
Hello, guys.

I must be doing something stupid or the tool (VC++ 6.0) I am using may not be the right one..

I need to build a "virtual printer driver". I am quite new on this area of developing, and many recommanded I'd better study the DDK print sample source code first and read some DDK documentation. I found the DDK documentation is not helping me understanding much on the subject.. so I tried the sample source code ( /genprint and /oemdll )

I am using Visual C++ 6.0, which I don't use everyday.
I thought I needed to create a project, so I chose Win32 DLL project with "empty DLL project" option. Next, I added the source files into the project, including the DDK and SDK paths in "Options".

When I tried to build - just for the heck of it - , what I got is a bunch of errors:
- 'struct' type redefinition
- 'try' & 'except': undeclared identifier
and even syntax errors...

The html files (about how to build) in the same directory are useless.

Could you be kindly enough to explain or give some instructions about how to build those sample source code from DDK print with VC++ 6.0??


Confused and frustrated
0
Comment
Question by:alexzen
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 6
  • 4
  • 3
  • +2
15 Comments
 
LVL 86

Expert Comment

by:jkr
ID: 8228063
Check out http://www.codeguru.com/system/KbdClass.shtml ("Using the Visual Studio 6.0 Driver Build Environment "), this will explain what you have to do.
0
 

Author Comment

by:alexzen
ID: 8228332
Thank you very much, jkr.
I am taking a look at it and will get back to you as soon as possible.
Thank you again.

alexzen
0
 
LVL 9

Expert Comment

by:BeyondWu
ID: 8237069
try to open the sources.inc and then make the same setting under VC's IDE.
0
 [eBook] Windows Nano Server

Download this FREE eBook and learn all you need to get started with Windows Nano Server, including deployment options, remote management
and troubleshooting tips and tricks

 

Author Comment

by:alexzen
ID: 8239251
hi, BeyondWu. how are you doing?
I took a look at the sources or sources.inc files, however, my knowledge on VC++ IDE is rusty and honestly, I am not sure I understand what I am looking at in those files, which means not sure what to do next on setting the VC++ IDE environment. (I just started studying the jkr's articles..)

Could you elaborate your comment on how to set the VC++'s IDE.. I mean where(under which menu/what dialogbox) should I make the change, if necessary?? (I hope I don't take too much time of yours..)

Thank you, guys..
0
 
LVL 49

Expert Comment

by:DanRollins
ID: 8241007
Device driver authoring is hardly a place to start your VC++ experience!  Once you have a few standard applications under your belt, then try writing a few DLL projects and and a test-harness EXE for testing purposes.  Once you have a firm grasp on how to use the IDE, the information in jkr's link will make a lot of sense and will solve your problem.

In the mean time, you can use VC++ as the editr and just use the command-line build batch files that come with the DDK.

I wonder about all of these recnet "virtual printer driver" questions.  Did somebody put a fat fee on Rent-a-Coder or something?

-- Dan
0
 

Author Comment

by:alexzen
ID: 8241439
Thank you for your comment, DanRollins. I appreciate any input. Yes, what you are suggesting is the proper steps toward any application development project. But sometimes fortuna(goddess of luck) just passes by, leaving us doing without reasonable resources or assistance, which is my case at the moment.
So could you generously elaborate what those are the command-line build batch files and how to use them?? please don't roll your eyes.., and imagine that you today walk someone home safely..

Thanks and have a good evening, guys.

alexzen
0
 
LVL 49

Expert Comment

by:DanRollins
ID: 8241674
I've only messed around in the driver area once or twice.  I downloaded the project and there was a build.bat file in with the other files.  I recall having to execute the one of the setenv batch files also.

So, is this a Rent-a-coder project?  Curiosity overcomes me.
-- Dan
0
 

Author Comment

by:alexzen
ID: 8241747
Thank you, DanRollins.
First off, this is not a Rent-a-coder project, it's one of internal projects from our company.
Could you tell me where you downloaded the project you mentioned??

Thanks..
0
 
LVL 49

Expert Comment

by:DanRollins
ID: 8241892
For what it's worth, I download the RAMDISK.SYS device driver source code.  
     http://support.microsoft.com/default.aspx?scid=kb%3Ben-us%3B257405

I presume that there are other examples that are more relevant to your problem.  One other thing, I havd to make sure that the the default directory was the the one with the source code before running the MAKE utility.

-- Dan
0
 
LVL 9

Expert Comment

by:BeyondWu
ID: 8243996
Hi alexzen,
I'm fine thank you. How are you?
I will give you the process on how to convert ddk's makefile into VC's project tomorrow. sorry I'm very busy recently.:(
0
 
LVL 9

Accepted Solution

by:
BeyondWu earned 800 total points
ID: 8258146
sorry for my later response.
I use the "oemuni" sample under ddk folder, please follow me;)
1. Create a New "Win32 Dynamic-Link Library "project.
2. Input a name(any string) into the "Project Name" edit box.
3. Press [OK], then select "a simple dll project", I think you also can select "an empty dll project", but I've tested it.
4. press [finish].
5. delete all files from the left project window.
6. copy all files from the "oemuni" subfolder into current project folder.
7. add all files into current project.(I assume you know how to do it).
8. open source.inc file.
9. if there is a line "PRECOMPILED_CXX=1", it means using precompile head.
10. select "xxx files" from the left workspace window.
11. press right button of mouse, in the popup menu, select "settings..." item.
12.select "C/C++" tab.
13.select "Precompiled Headers" from the "Category" comobox.
14.select "Use Precompiled Header file (.pch)". then input "precomp.h" in the "through header:" edit box.
15.press [OK].
16.from the sources.inc, there is a line:
C_DEFINES=$(C_DEFINES) -DKERNEL_MODE -D_UNICODE -DUNICODE -DOEMCOM
-DKERNEL_MODE means define "KERNEL_MODE"
so open the setting dialogbox again(refer item 10), then select "C/C++" tab, and select General from "Category" comobox, in the "Preprocessor definitions:" edit box, input all the symbol copy from the sources.inc.
these are "KERNEL_MODE,_UNICODE,UNICODE,OEMCOM,DEBUG,USERMODE_DRIVER"
the USERMODE_DRIVER comes from the file "sources" under the umode subfolder.
17.still in the "C/C++" tab, select the "Preprocessor" from the "Category" comobox, input your ddk's include dir into the "Aditional include directories:" edit box.
for me, it is "F:\WINDDK\inc"
18.there is a line "DLLBASE=0x70000000", so you need to open the setting dialogbox again, select "Link" tab. then select "Output" from the "Category" comobox, input the "0x70000000" into the "Base Address:" editbox.
19.there is also a def in the umode folder. so please add this file into your project.
20.for this sample, the "precomp.h" file is a precompiled header file, but for VC's IDE we need a .cpp to use it.
so please create a new .cpp file and insert the line "#include "precomp.h" into the cpp file, then add this cpp file into your project, then select the cpp file in the left workspce window, press right button, in the popup menu, select "setting..." item, select "Precompiled Headers:" from the "catagory" comobox, then select the "Create precompiled header ...", then input the "precomp.h" into the following "Through header" edit box.

OK, that's all.:) hope this help you.
0
 

Author Comment

by:alexzen
ID: 8263446
Dear BeyondWu,

I am so impressed with your step-by-step instructions. I have to tell you that it is so hard to experience this kind of generosity these days. I really appreciate it. You will definitely get my points.

I have one last question for you, if I may. The program was built successfully and I got the dll now. And I am not sure what to do with this dll. I think I am supposed to use the dll to add a printer. Can I simply use the oemdll.inf??

And forgive me quoting this poem:
...
Expect nothing.
Live frugally on surprise. – Alice Walker

Thank you for the pleasant surprise.
Good day, BeyondWu.

alexzen


0
 
LVL 9

Expert Comment

by:BeyondWu
ID: 8265966
Dear alexzen,

For the samples of ddk, there is always a corresponding .htm file to indicate how to install it, yea, for this sample, you can use the oemdll.inf to install it. please refer "INF File Sections and Directives" for more details of .inf file. I recommend you first study the section "Display and Print Device" at least, before you begin to code for your Printer Driver. You also need to know how to debug it, I'd like to use SoftIce...

Good day, and you are welcome.
Wu
0
 

Author Comment

by:alexzen
ID: 8269963
Thank you so much all guys. I appreciate all your comments. Especially BeyondWu. I now at least have something to go forward thanks to all your help I was given. Thank you again and have a greate weekend.

alexzen

0
 

Expert Comment

by:stibnite
ID: 8811876
Dear Sir:

I have a similar situation. I tried to compile the sample source from the ddk just by the command of "build -cz" . I got a error like this:

precomp.obj() : error; intenal error during Pass 2.

Can any friend tell me what is wrong in my work? What i did is just use the original source code. Should i change something in the source code?


Thanks in advence

Regards,
andy
0

Featured Post

Want to be a Web Developer? Get Certified Today!

Enroll in the Certified Web Development Professional course package to learn HTML, Javascript, and PHP. Build a solid foundation to work toward your dream job!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article describes how to programmatically preset the "Pages per Sheet" option that's available with most printer drivers.   This setting lets you do "n-Up" printing, where two, four, or more pages are printed on each sheet of paper. If your …
For a while now I'v been searching for a circular progress control, much like the one you get when first starting your Silverlight application. I found a couple that were written in WPF and there were a few written in Silverlight, but all appeared o…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …

801 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question