 |
BorlandTalk.com Borland discussion newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
Jim W. Guest
|
Posted: Thu Oct 26, 2006 6:18 am Post subject: Accessing Vista Functions in C |
|
|
I'm using the Borland Command Line Compiler and working in straight C.
The system is Windows Vista RC1.
I'm trying to implement an interface to the new Vista UI's that are not
available in XP.
So here is what I have so far.
I have the manifest setup to bring in version 6 of the comctl32.dll.
I defined a function as:
int* (*TaskDialogProc)(HWND hwnd,HINSTANCE hinst,char *s1,char *s2, char
*s3,int i, int j, int *k);
<snip>
int res = 0;
HANDLE DllHandle;
<snip>
DllHandle = LoadLibrary("comctl32.dll");
if (DllHandle >= 32) {
TaskDialogProc = GetProcAddress(DllHandle,"TaskDialog");
iret = (*TaskDialogProc)(NULL, NULL, L"Title", L"String1",L"String2",
1, 102, &res);
}
This displays the Vista TaskDialog with the strings and the OK
button and the Question Mark icon as it should -- but the program simply
"goes away" after
I hit the OK button on the TaskDialog.
My best guess is the stack is getting messed up. I put a MessageBox after
the call to check the return value but it doesn't get to it.
Any help would be appreciated.
JimW |
|
| Back to top |
|
 |
Ed Mulroy Guest
|
Posted: Sat Oct 28, 2006 4:31 am Post subject: Re: Accessing Vista Functions in C |
|
|
Windows does not use C calling convention except for rare functions such as
wsprintf. Most of the functions use __stdcall calling conventions. WINAPI
is a macro in the Windows headers which translates to __stdcall. Using the
wrong calling convention will mess up the stack and probably generate
symptoms such as you describe. Try adding WINAPI.
I also wonder about the extra asterisk used here:
| Quote: | int* (*TaskDialogProc)(HWND hwnd,HINSTANCE hinst,
char *s1,char *s2, char *s3,int i, int j, int *k);
|
Does it return a pointer to int or an int? Your code is as if it is an int
and not an int*. It looks as if the asterisk between the 'int' and the
opening parentheses should be removed.
Maybe this will work better:
int (* WINAPI TaskDialogProc)(HWND hwnd,HINSTANCE hinst,
char *s1,char *s2, char *s3,int i, int j, int *k);
.. Ed
| Quote: | Jim W wrote in message
news:J1U%g.18656$A27.18410@trnddc08...
I'm using the Borland Command Line Compiler and working in straight C. The
system is Windows Vista RC1.
I'm trying to implement an interface to the new Vista UI's that are not
available in XP.
So here is what I have so far.
I have the manifest setup to bring in version 6 of the comctl32.dll.
I defined a function as:
int* (*TaskDialogProc)(HWND hwnd,HINSTANCE hinst,
char *s1,char *s2, char *s3,int i, int j, int *k);
snip
int res = 0;
HANDLE DllHandle;
snip
DllHandle = LoadLibrary("comctl32.dll");
if (DllHandle >= 32) {
TaskDialogProc = GetProcAddress(DllHandle,"TaskDialog");
iret = (*TaskDialogProc)(NULL, NULL, L"Title", L"String1",
L"String2", 1, 102, &res);
}
This displays the Vista TaskDialog with the strings and the OK
button and the Question Mark icon as it should -- but the program simply
"goes away" after
I hit the OK button on the TaskDialog.
My best guess is the stack is getting messed up. I put a MessageBox after
the call to check the return value but it doesn't get to it.
Any help would be appreciated. |
|
|
| Back to top |
|
 |
Jim W. Guest
|
Posted: Sat Oct 28, 2006 6:41 am Post subject: Re: Accessing Vista Functions in C |
|
|
"Ed Mulroy" <dont_email_me (AT) bitbuc (DOT) ket> wrote in message
news:454296df$1 (AT) newsgroups (DOT) borland.com...
| Quote: | Windows does not use C calling convention except for rare functions such
as wsprintf. Most of the functions use __stdcall calling conventions.
WINAPI is a macro in the Windows headers which translates to __stdcall.
Using the wrong calling convention will mess up the stack and probably
generate symptoms such as you describe. Try adding WINAPI.
I also wonder about the extra asterisk used here:
int* (*TaskDialogProc)(HWND hwnd,HINSTANCE hinst,
char *s1,char *s2, char *s3,int i, int j, int *k);
Does it return a pointer to int or an int? Your code is as if it is an
int and not an int*. It looks as if the asterisk between the 'int' and
the opening parentheses should be removed.
Maybe this will work better:
int (* WINAPI TaskDialogProc)(HWND hwnd,HINSTANCE hinst,
char *s1,char *s2, char *s3,int i, int j, int *k);
|
Ed,
Thanks. I was just about to answer my own post with the solution. The
Win32 group offered it up.
int* (__stdcall *TaskDialogProc)(HWND hwnd, HINSTANCE hinst, char *a,
char*b, char *c, int i, int d, int *k);
It working just fine now.
JimW |
|
| Back to top |
|
 |
Ed Mulroy Guest
|
Posted: Sat Oct 28, 2006 6:19 pm Post subject: Re: Accessing Vista Functions in C |
|
|
That still prototypes it as returning a pointer to int and you are then
assigning the return value to an int. Sure you can "get away with it" until
such time as you don't and then it wil be a debug session to find out what
is wrong.
If it returns an int, prototype it as returning an int, not a pointer to
int.
.. Ed
| Quote: | Jim W wrote in message
news:4zy0h.101$CT5.55@trnddc02...
Thanks. I was just about to answer my own post with the solution. The
Win32 group offered it up.
int* (__stdcall *TaskDialogProc)(HWND hwnd, HINSTANCE hinst, char *a,
char*b, char *c, int i, int d, int *k);
It working just fine now. |
|
|
| Back to top |
|
 |
Jim W. Guest
|
Posted: Sat Oct 28, 2006 8:20 pm Post subject: Re: Accessing Vista Functions in C |
|
|
"Ed Mulroy" <dont_email_me (AT) bitbuc (DOT) ket> wrote in message
news:454359ba (AT) newsgroups (DOT) borland.com...
| Quote: | That still prototypes it as returning a pointer to int and you are then
assigning the return value to an int. Sure you can "get away with it"
until such time as you don't and then it wil be a debug session to find
out what is wrong.
If it returns an int, prototype it as returning an int, not a pointer to
int.
. Ed
Thanks Ed, |
I was so excited about getting a TaskDialog up your post didn't register.
Thanks for being persistent.
JimW |
|
| Back to top |
|
 |
|
|
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
|
|