Hi Eveyone,

I'm trying to use PrintDlgEx

When i try to compile my code, the compiler couldn't recognise PrintExDlg. I'm sure my syntax is correct.
The minimum operating systems required is Windows 2000. I'm using XP.

A check on my .h files (commdlg.h,windows.h) shows that they are not updated. Where can i get the latest .h and .lib files?
Or should i update them myself?

Thanks!
Posted on 2004-04-11 23:39:56 by trexxz
Assuming that you are using MASM32 and not C as this is an assembly forum and C questions would belong in the heap, be sure to include the following at the top of your code...

include comdlg32.inc
includelib comdlg32.lib
Posted on 2004-04-11 23:55:37 by donkey
Donkey,

Yeah. I'm using MASM32 and i have "include comdlg32.inc" and "includelib comdlg32.lib".
Posted on 2004-04-12 00:11:30 by trexxz
I was sure that since you used .H files you were talking about C. You can download the latest include files at the masm forum or just include the following in your comdlg.inc and recompile the lib with inc2lib or whatever it's called...

PrintDlgExA PROTO :DWORD
PrintDlgEx equ <PrintDlgExA>
Posted on 2004-04-12 00:14:54 by donkey
Donkey,
That's my mistake. I meant .inc file but i typed .h

i tried inserting the 2 lines into comdlg.inc and recompile the lib using inc2l.exe
The code compilation returns no errors.

Will the program knows it has the perform the required operations? What i did was just declaring the method.

When i run my code, invoke PrintDlgEx does not do anything.
Posted on 2004-04-12 02:18:56 by trexxz
What does GetLastError return ? I have never used the dialog but like most Common Dialogs it is probably very picky about its structures initialization, especially cbSize and the parent handle you pass to it. You might start to check there.
Posted on 2004-04-12 02:25:54 by donkey
The error message is:
error A2006: undefined symbol : PrintDlgEx

Line of code:
invoke PrintDlgEx, ADDR pDlgEx

The reason why i want to use PrintDlgEx is:

Using PrintDlg is fine on Windows 98. OllyDbg picks up nothing.
However on Windows XP, OllyDbg picks up this access violation during runtime.

Log data, item 0
Address=763BAAFC
Message=Access violation when reading [00171000]

Call stack of main thread, item 2
Address=0012FC90
Stack=0040A478
Procedure / arguments=? <JMP.&comdlg32.PrintDlgA>
Called from=Propheci.0040A473

From the MSDN library, it states "Windows 2000/XP: The PrintDlg function has been superseded by the PrintDlgEx function."
So i thought i'll give it a go.

:notsure:
Posted on 2004-04-12 02:41:30 by trexxz
Well,

PrintDlg will still work under XP and 2K, they never remove a function, just offer another one in addition to it. You should check to see why you are getting the access violation in XP. Under 98 your program will not run if you use a lib based version of PrintDlgEx, you will have to load it dynamically...

In GoAsm :
invoke GetModuleHandle,"ComDlg32.dll"

invoke GetProcAddress, eax, "PrintDlgExA"
mov [pPrintDlgEx], eax

push offset pdxstruct
call [pPrintDlgEx]
Posted on 2004-04-12 02:49:31 by donkey
Thanks Donkey. :alright:

I'll look into it.
Posted on 2004-04-12 02:55:33 by trexxz
When a Win9x program doesn't work properly on XP, the first thing that always comes to mind is: are you expecting the API to leave ECX and EDX unchanged? That would be bad.

It looks like it has been a while since the register preservation convention has been mentioned. Here it is...

Caller-save registers (caller must save, if needed)
EAX, ECX, EDX

Callee-save registers (subroutine must save, if used)
EBX, ESI, EDI

If you use PROC, the EBP and ESP registers are handled automatically.

If you are changing DF (direction/descending flag), it must be cleared before returning, and before calling other subroutines (especially the APIs).

You can break the rules only within code that 1) doesn't call APIs or HLL generated subroutines, and 2) doesn't return to "Windows" or another HLL generated module.
Posted on 2004-04-12 16:20:52 by tenkey
Noted. Cheers tenkey
Posted on 2004-04-12 20:49:09 by trexxz