ULONG*

J

John Harrison

alex said:
how do i initialize an atl ULONG* variable?

Same way as any other variable.

ULONG* x = something;

If you are having some trouble with code, it is best to post the actual
code.

john
 
K

Karl Heinz Buchegger

alex said:
[snip]
ULONG* pnChars = 50; does not compile (int)

ULONG* pnChars = 50.0; does not compile (double)

Man. The * in ULONG* means something!
It denotes a pointer! Neither 50 nor 50.0 are pointers.
ULONG* pnChars = 0; compiles but causes assertion failure when used in:

if ( MyCRegKey.QueryStringValue(valName.c_str(), pszValue, pnChars) ==
ERROR_SUCCESS )

Chances are high, that this function just wants to know the address of a variable
where it should place the result:

ULONG nChars;

if ( MyCRegKey.QueryStringValue(valName.c_str(), pszValue, &nChars) ==
ERROR_SUCCESS )

Not in every case when there is a pointer variable in an argument list it means
that you pass a pointer variable. In fact most of the time you simply pass
the address of a variable. Reading the documentation closely usually clearifies
things.
 
J

John Harrison

ULONG* pnChars = 50; does not compile (int)

ULONG* pnChars = 50.0; does not compile (double)

ULONG* pnChars = 0; compiles but causes assertion failure when used in:

if ( MyCRegKey.QueryStringValue(valName.c_str(), pszValue, pnChars) ==
ERROR_SUCCESS )

MyCRegKey is an object instantiated from CRegKey -- a microsoft class that
wraps the registry functions.

for this QueryStringValue issue I think I'll just call one or more of the
registry functions directly, that should take care

of things, it would be good to know how to handle this though.

Common newbie mistake. Just because a function takes a pointer argument it
doesn't mean that you have to declare a pointer variable. Just declare a
ULONG (no pointer) and use the address of operator.

ULONG nChars;
if ( MyCRegKey.QueryStringValue(valName.c_str(), pszValue, &nChars) ==
ERROR_SUCCESS )

john
 
A

alex

John Harrison said:
Common newbie mistake. Just because a function takes a pointer argument it
doesn't mean that you have to declare a pointer variable. Just declare a
ULONG (no pointer) and use the address of operator.

ULONG nChars;
if ( MyCRegKey.QueryStringValue(valName.c_str(), pszValue, &nChars) ==
ERROR_SUCCESS )

john

yeah, that worked, thanks!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Staff online

Members online

Forum statistics

Threads
473,755
Messages
2,569,534
Members
45,007
Latest member
obedient dusk

Latest Threads

Top