Connecting Tech Pros Worldwide Help | Site Map

ULONG*

  #1  
Old July 22nd, 2005, 03:06 PM
alex
Guest
 
Posts: n/a
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 =---
  #2  
Old July 22nd, 2005, 03:06 PM
John Harrison
Guest
 
Posts: n/a

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


  #3  
Old July 22nd, 2005, 03:45 PM
alex
Guest
 
Posts: n/a

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 =---
  #4  
Old July 22nd, 2005, 04:15 PM
Karl Heinz Buchegger
Guest
 
Posts: n/a

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
  #5  
Old July 22nd, 2005, 04:15 PM
John Harrison
Guest
 
Posts: n/a

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


  #6  
Old July 22nd, 2005, 04:15 PM
alex
Guest
 
Posts: n/a

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Representing a ulong as An Array of Bytes AK_TIREDOFSPAM@hotmail.COM answers 12 August 18th, 2006 09:45 PM
ulong vs UInt64 Sanjib Biswas answers 9 July 5th, 2006 03:15 AM
ulong vs UInt64 Sanjib Biswas answers 9 July 5th, 2006 03:15 AM
Negative int to positive ulong? Curt Krueger answers 3 November 16th, 2005 09:23 AM