Connecting Tech Pros Worldwide Forums | Help | Site Map

ULONG*

alex
Guest
 
Posts: n/a
#1: Jul 22 '05
how do i initialize an atl ULONG* variable?






----== Posted via Newsfeed.Com - Unlimited-Uncensored-Secure Usenet News==----
http://www.newsfeed.com The #1 Newsgroup Service in the World! >100,000 Newsgroups
---= 19 East/West-Coast Specialized Servers - Total Privacy via Encryption =---

John Harrison
Guest
 
Posts: n/a
#2: Jul 22 '05

re: ULONG*



"alex" <alex.smotritsky@verizon.net> wrote in message
news:40d925d9$1_2@127.0.0.1...[color=blue]
> how do i initialize an atl ULONG* variable?
>[/color]

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


alex
Guest
 
Posts: n/a
#3: Jul 22 '05

re: ULONG*



"John Harrison" <john_andronicus@hotmail.com> wrote in message
news:2jsoivF14sfrpU1@uni-berlin.de...[color=blue]
>
> "alex" <alex.smotritsky@verizon.net> wrote in message
> news:40d925d9$1_2@127.0.0.1...[color=green]
> > how do i initialize an atl ULONG* variable?
> >[/color]
>
> 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
>
>[/color]

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.

here's the method description:

http://msdn.microsoft.com/library/de...tringvalue.asp

but i'm just gonna use RegQueryValueEx from:

http://msdn.microsoft.com/library/de..._functions.asp

that should do it.






----== Posted via Newsfeed.Com - Unlimited-Uncensored-Secure Usenet News==----
http://www.newsfeed.com The #1 Newsgroup Service in the World! >100,000 Newsgroups
---= 19 East/West-Coast Specialized Servers - Total Privacy via Encryption =---
Karl Heinz Buchegger
Guest
 
Posts: n/a
#4: Jul 22 '05

re: ULONG*


alex wrote:[color=blue]
>[/color]
[snip][color=blue]
> ULONG* pnChars = 50; does not compile (int)
>
> ULONG* pnChars = 50.0; does not compile (double)
>[/color]

Man. The * in ULONG* means something!
It denotes a pointer! Neither 50 nor 50.0 are pointers.
[color=blue]
> ULONG* pnChars = 0; compiles but causes assertion failure when used in:
>
> if ( MyCRegKey.QueryStringValue(valName.c_str(), pszValue, pnChars) ==
> ERROR_SUCCESS )[/color]

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.


--
Karl Heinz Buchegger
kbuchegg@gascad.at
John Harrison
Guest
 
Posts: n/a
#5: Jul 22 '05

re: ULONG*


>[color=blue]
> 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[/color]
that[color=blue]
> 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.
>[/color]

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


alex
Guest
 
Posts: n/a
#6: Jul 22 '05

re: ULONG*



"John Harrison" <john_andronicus@hotmail.com> wrote in message
news:2jt2s3F152hj6U1@uni-berlin.de...[color=blue][color=green]
> >
> > 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[/color]
> that[color=green]
> > wraps the registry functions.
> >
> > for this QueryStringValue issue I think I'll just call one or more of[/color][/color]
the[color=blue][color=green]
> > registry functions directly, that should take care
> >
> > of things, it would be good to know how to handle this though.
> >[/color]
>
> 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
>
>
>[/color]

yeah, that worked, thanks!






----== Posted via Newsfeed.Com - Unlimited-Uncensored-Secure Usenet News==----
http://www.newsfeed.com The #1 Newsgroup Service in the World! >100,000 Newsgroups
---= 19 East/West-Coast Specialized Servers - Total Privacy via Encryption =---
Closed Thread