Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

type of HINSTANCE?

925 views
Skip to first unread message

William Payne

unread,
Aug 4, 2003, 9:17:33 PM8/4/03
to
Hello, I would like to know what C-type HINSTANCE is? By browsing through
documentation and grepping through the sources (of the latest platform SDK),
I've been able to determine that HINSTANCE__* and HMODULE both are aliases
for HINSTANCE. But what is the C base type that lies beneath all the
typedefs? It's not void*, I know that much.

// William Payne


Lucian Wischik

unread,
Aug 5, 2003, 4:41:01 AM8/5/03
to

It's not a mystery! To find out, (if you're using Visual Studio) you
can right-click on HINSTANCE and "go to definition". (if you're using
some other IDE then you'll have to just search through the windows
include files until you find it).

This takes you to a line in windef.h,
DECLARE_HANDLE(HINSTANCE)

Again, "go to definition" of DECLARE_HANDLE takes you to winnt.h:
#ifdef STRICT
typedef void *HANDLE;
#define DECLARE_HANDLE(name) struct name##__ { int unused; }; typedef
struct name##__ *name
#else
typedef PVOID HANDLE;
#define DECLARE_HANDLE(name) typedef HANDLE name
#endif
typedef HANDLE *PHANDLE;

The 'strict' form uses a dummy struct purely for type-system
sneakiness, so that you can't assign one handle to another. That's why
you should always have 'STRICT' defined in your project settings!

--
Lucian

Michael Winter

unread,
Aug 5, 2003, 8:27:20 PM8/5/03
to
> I've been able to determine that HINSTANCE__* and HMODULE both are
> aliases for HINSTANCE. But what is the C base type that lies beneath all
> the typedefs? It's not void*, I know that much.

To a degree, you're wrong there. The construct used depends upon whether
STRICT has been #define'd (which is enabled by default, though I've never
seen in the project settings or the command line, so I define it
just-in-case).

When STRICT is not #define'd, you do end up with a void-pointer:

typedef HINSTANCE PVOID; // essentially

When STRICT has been #define'd, you get this:

struct HINSTANCE__
{
int unused;
};
typedef HINSTANCE__ * HINSTANCE;


Michael Winter

--
M.Winter@(I_hate_spam)blueyonder.co.uk
Remove "(I_hate_spam)" to reply.

"William Payne" <mikas493...@student.liu.se> wrote in message
news:bgn0hd$cte$1...@news.island.liu.se...

0 new messages