For Programmers: Free Programming Magazines  


Home > Archive > VC Language > May 2006 > use windef.h in IDL









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author use windef.h in IDL
ccwork

2006-05-29, 8:11 am

Hi,
I want to define a function as:
interface db
{
BOOL isUser(HWND hWnd, char *name);
}

Obviously "BOOL" and "HWND" are unknown to MIDL and MIDL complains a
type expectation. So I add #include "windef.h":
interface db
{
#include "windef.h"
BOOL isUser(HWND hWnd, char *name);
}

Here a problem comes. MIDL complains there is redefinition of some
structure inside windef.h. I never redefine them actually. How can I correct
this error?
Thanks.
Carl Daniel [VC++ MVP]

2006-05-29, 7:12 pm

ccwork wrote:
> Hi,
> I want to define a function as:
> interface db
> {
> BOOL isUser(HWND hWnd, char *name);
> }
>
> Obviously "BOOL" and "HWND" are unknown to MIDL and MIDL complains
> a type expectation. So I add #include "windef.h":
> interface db
> {
> #include "windef.h"
> BOOL isUser(HWND hWnd, char *name);
> }
>
> Here a problem comes. MIDL complains there is redefinition of some
> structure inside windef.h. I never redefine them actually. How can I
> correct this error?


Outside your interface, you need to #import <wtypes.idl>, e.g.

#import <unknwn.idl>
#import <wtypes.idl>

[ ... ]
interface db
{
BOOL isUser(HWND hWnd, char* name);
}

-cd


ccwork

2006-05-29, 7:12 pm

"Carl Daniel [VC++ MVP]" wrote:

> ccwork wrote:
>
> Outside your interface, you need to #import <wtypes.idl>, e.g.
>
> #import <unknwn.idl>
> #import <wtypes.idl>
>
> [ ... ]
> interface db
> {
> BOOL isUser(HWND hWnd, char* name);
> }
>
> -cd

Indeed this is a RPC wrapper for existing library. This local procedure
gets the windows handle and send back WM ...... I am not sure it is possible
throught RPC. Did anyone try it before? Can a remote PC use the hWnd to send
mesage back to client?
Carl Daniel [VC++ MVP]

2006-05-29, 7:12 pm

ccwork wrote:
> Indeed this is a RPC wrapper for existing library. This local
> procedure gets the windows handle and send back WM ...... I am not
> sure it is possible throught RPC. Did anyone try it before? Can a
> remote PC use the hWnd to send mesage back to client?


Not directly - the HWND has no meaning outside the desktop session in which
it was created. You'd have to have a service on the original machine that
sends the message to the HWND.

-cd


ccwork

2006-05-29, 10:04 pm

"Carl Daniel [VC++ MVP]" wrote:

> ccwork wrote:
>
> Outside your interface, you need to #import <wtypes.idl>, e.g.
>
> #import <unknwn.idl>
> #import <wtypes.idl>
>
> [ ... ]
> interface db
> {
> BOOL isUser(HWND hWnd, char* name);
> }
>
> -cd


Hi Carl,
It works! Thanks! Another problem just comes up :O
I need to use the struct defined in "db.h" and therefore I "import" it:
<...>
import "wtypes.idl";
import "CommonHeader\db.h";
interface db { ... }
<...>
The generated "db.h", however, thinks the "db.h" is at current level:
#include "db.h"

Of course this is wrong: "db.h" is in ".\CommonHeader". Why does this
happen? And how to fix?
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com