Connecting Tech Pros Worldwide Help | Site Map

ULONG*

 
LinkBack Thread Tools Search this Thread
  #1  
Old July 22nd, 2005, 02:06 PM
alex
Guest
 
Posts: n/a
Default ULONG*

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, 02:06 PM
John Harrison
Guest
 
Posts: n/a
Default 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, 02:45 PM
alex
Guest
 
Posts: n/a
Default 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, 03:15 PM
Karl Heinz Buchegger
Guest
 
Posts: n/a
Default 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, 03:15 PM
John Harrison
Guest
 
Posts: n/a
Default 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, 03:15 PM
alex
Guest
 
Posts: n/a
Default 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 =---
 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Popular Articles

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over 220,662 network members.