www.digitalmars.com         C & C++   DMDScript  

D - registry

reply "Carlos Santander B." <carlos8294 msn.com> writes:
Hi,
I'm trying to access the Windows Registry, so I'm using RegOpenKeyA(). The
thing is that this function receives an HKEY, which is a HANDLE, which is an
int. But I want to open HKEY_LOCAL_MACHINE, which value is 0x80000002, that
is an uint. I tried to declare RegOpenKeyA() in windows.d to receive an
uint, but the linker complained (I think that's pretty obvious). What should
I do?
What I'm trying to do is to get the processor's description. I know I can do
it calling the Win32 API, but if I use the registry I don't need to parse
the information I get. Besides, later I need to get the list of installed
programs, which is also in the registry. So it seems like I don't have a
choice. Any ideas?


-------------------------
Carlos Santander


---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.465 / Virus Database: 263 - Release Date: 2003-03-25
Mar 27 2003
parent reply "Jon Allen" <jallen minotstateu.edu> writes:
HKEY_LOCAL_MACHINE should be declared as an HKEY, and HANDLE should be a
void*

You should check to make sure your windows.d is up to date.

"Carlos Santander B." <carlos8294 msn.com> wrote in message
news:b5vs1h$2eq3$1 digitaldaemon.com...
 Hi,
 I'm trying to access the Windows Registry, so I'm using RegOpenKeyA(). The
 thing is that this function receives an HKEY, which is a HANDLE, which is
an
 int. But I want to open HKEY_LOCAL_MACHINE, which value is 0x80000002,
that
 is an uint. I tried to declare RegOpenKeyA() in windows.d to receive an
 uint, but the linker complained (I think that's pretty obvious). What
should
 I do?
 What I'm trying to do is to get the processor's description. I know I can
do
 it calling the Win32 API, but if I use the registry I don't need to parse
 the information I get. Besides, later I need to get the list of installed
 programs, which is also in the registry. So it seems like I don't have a
 choice. Any ideas?


 -------------------------
 Carlos Santander


 ---
 Outgoing mail is certified Virus Free.
 Checked by AVG anti-virus system (http://www.grisoft.com).
 Version: 6.0.465 / Virus Database: 263 - Release Date: 2003-03-25
Mar 27 2003
parent reply "Carlos Santander B." <carlos8294 msn.com> writes:
"Jon Allen" <jallen minotstateu.edu> escribiσ en el mensaje
news:b607au$2o9g$1 digitaldaemon.com...
| HKEY_LOCAL_MACHINE should be declared as an HKEY, and HANDLE should be a
| void*
|
| You should check to make sure your windows.d is up to date.
|

Well, HKEY_LOCAL_MACHINE is an HKEY, which is a HANDLE, which is an int.

—————————————————————————
Carlos Santander


---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.465 / Virus Database: 263 - Release Date: 2003-03-25
Mar 27 2003
parent reply "Carlos Santander B." <carlos8294 msn.com> writes:
"Carlos Santander B." <carlos8294 msn.com> escribiσ en el mensaje
news:b60jc0$30ob$1 digitaldaemon.com...
| "Jon Allen" <jallen minotstateu.edu> escribiσ en el mensaje
| news:b607au$2o9g$1 digitaldaemon.com...
| | HKEY_LOCAL_MACHINE should be declared as an HKEY, and HANDLE should be a
| | void*
| |
| | You should check to make sure your windows.d is up to date.
| |
|
| Well, HKEY_LOCAL_MACHINE is an HKEY, which is a HANDLE, which is an int.
|
|

My mistake. In order to compile windows.d, I had to declare
HKEY_LOCAL_MACHINE as an uint, because otherwise it wouldn't compile. And
not only HKEY_LOCAL_MACHINE: a lot of other const's too...

—————————————————————————
Carlos Santander
"Carlos Santander B." <carlos8294 msn.com> escribiσ en el mensaje
news:b60jc0$30ob$1 digitaldaemon.com...
| "Jon Allen" <jallen minotstateu.edu> escribiσ en el mensaje
| news:b607au$2o9g$1 digitaldaemon.com...
| | HKEY_LOCAL_MACHINE should be declared as an HKEY, and HANDLE should be a
| | void*
| |
| | You should check to make sure your windows.d is up to date.
| |
|
| Well, HKEY_LOCAL_MACHINE is an HKEY, which is a HANDLE, which is an int.
|
|

My mistake. In order to compile windows.d, I had to declare
HKEY_LOCAL_MACHINE as an uint, because otherwise it wouldn't compile. And
not only HKEY_LOCAL_MACHINE: a lot of other const's too...

—————————————————————————
Carlos Santander
Mar 27 2003
parent reply "Jon Allen" <jallen minotstateu.edu> writes:
the windows.d i have does it like this:

enum : HKEY
{
    //stuff
    HKEY_LOCAL_MACHINE=((HKEY)0x80000002)
    //stuff
}

i bet this would work too though:

const HKEY HKEY_LOCAL_MACHINE=cast(HKEY)0x80000002;

"Carlos Santander B." <carlos8294 msn.com> wrote in message
news:b60joi$311f$1 digitaldaemon.com...
 "Carlos Santander B." <carlos8294 msn.com> escribiσ en el mensaje
 news:b60jc0$30ob$1 digitaldaemon.com...
 | "Jon Allen" <jallen minotstateu.edu> escribiσ en el mensaje
 | news:b607au$2o9g$1 digitaldaemon.com...
 | | HKEY_LOCAL_MACHINE should be declared as an HKEY, and HANDLE should be
a
 | | void*
 | |
 | | You should check to make sure your windows.d is up to date.
 | |
 |
 | Well, HKEY_LOCAL_MACHINE is an HKEY, which is a HANDLE, which is an int.
 |
 |

 My mistake. In order to compile windows.d, I had to declare
 HKEY_LOCAL_MACHINE as an uint, because otherwise it wouldn't compile. And
 not only HKEY_LOCAL_MACHINE: a lot of other const's too...

 -------------------------
 Carlos Santander
 "Carlos Santander B." <carlos8294 msn.com> escribiσ en el mensaje
 news:b60jc0$30ob$1 digitaldaemon.com...
 | "Jon Allen" <jallen minotstateu.edu> escribiσ en el mensaje
 | news:b607au$2o9g$1 digitaldaemon.com...
 | | HKEY_LOCAL_MACHINE should be declared as an HKEY, and HANDLE should be
a
 | | void*
 | |
 | | You should check to make sure your windows.d is up to date.
 | |
 |
 | Well, HKEY_LOCAL_MACHINE is an HKEY, which is a HANDLE, which is an int.
 |
 |

 My mistake. In order to compile windows.d, I had to declare
 HKEY_LOCAL_MACHINE as an uint, because otherwise it wouldn't compile. And
 not only HKEY_LOCAL_MACHINE: a lot of other const's too...

 -------------------------
 Carlos Santander
Mar 27 2003
next sibling parent "Carlos Santander B." <carlos8294 msn.com> writes:
"Jon Allen" <jallen minotstateu.edu> escribiσ en el mensaje
news:b60kt4$ff$1 digitaldaemon.com...
| the windows.d i have does it like this:
|
| enum : HKEY
| {
|     //stuff
|     HKEY_LOCAL_MACHINE=((HKEY)0x80000002)
|     //stuff
| }
|
| i bet this would work too though:
|
| const HKEY HKEY_LOCAL_MACHINE=cast(HKEY)0x80000002;
|

Thanks, I'll check it out.

—————————————————————————
Carlos Santander


---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.465 / Virus Database: 263 - Release Date: 2003-03-26
Mar 27 2003
prev sibling parent reply "Carlos Santander B." <carlos8294 msn.com> writes:
"Jon Allen" <jallen minotstateu.edu> escribiσ en el mensaje
news:b60kt4$ff$1 digitaldaemon.com...
| the windows.d i have does it like this:
|
| enum : HKEY
| {
|     //stuff
|     HKEY_LOCAL_MACHINE=((HKEY)0x80000002)
|     //stuff
| }
|
| i bet this would work too though:
|
| const HKEY HKEY_LOCAL_MACHINE=cast(HKEY)0x80000002;
|

Well, doesn't work either. I still get: Error 42: Symbol Undefined
_RegOpenKeyA 12.

—————————————————————————
Carlos Santander


---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.465 / Virus Database: 263 - Release Date: 2003-03-26
Mar 27 2003
parent reply "Carlos Santander B." <carlos8294 msn.com> writes:
"Carlos Santander B." <carlos8294 msn.com> escribiσ en el mensaje
news:b60lsv$1dj$1 digitaldaemon.com...
| "Jon Allen" <jallen minotstateu.edu> escribiσ en el mensaje
| news:b60kt4$ff$1 digitaldaemon.com...
| | the windows.d i have does it like this:
| |
| | enum : HKEY
| | {
| |     //stuff
| |     HKEY_LOCAL_MACHINE=((HKEY)0x80000002)
| |     //stuff
| | }
| |
| | i bet this would work too though:
| |
| | const HKEY HKEY_LOCAL_MACHINE=cast(HKEY)0x80000002;
| |
|
| Well, doesn't work either. I still get: Error 42: Symbol Undefined
| _RegOpenKeyA 12.

Of course!!!!!!!!!!!!!!!!!!!!!!!!! I had no idea it needed
advapi32.lib....................
I'm gonna shoot myself!!!!!!!!!!!
(well, not so much)
also, for some reason, besides src\phobos\windows.d, I have a really old
Pavel's windows.d (more complete, though), and there's where I had all those
weird declarations.
my God!!!!!!!!!! how can a human being be sooooooooooooooo stupid?
By the way, dmd compiles (and links) my file just fine if I declare (since
it's not in Walter's windows.d) RegOpenKeyA as (void *,LPCSTR,PHKEY) or as
(int,LPCSTR,PHKEY). why? are void* and int the same? (I know they're not,
but still....)

—————————————————————————
Carlos Santander


---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.465 / Virus Database: 263 - Release Date: 2003-03-26
Mar 27 2003
next sibling parent reply "Jon Allen" <jallen minotstateu.edu> writes:
 Of course!!!!!!!!!!!!!!!!!!!!!!!!! I had no idea it needed
 advapi32.lib....................
 I'm gonna shoot myself!!!!!!!!!!!
 (well, not so much)
 also, for some reason, besides src\phobos\windows.d, I have a really old
 Pavel's windows.d (more complete, though), and there's where I had all
those
 weird declarations.
 my God!!!!!!!!!! how can a human being be sooooooooooooooo stupid?
Heh, go figure. Why is it always the simplest possible problem that is always the hardest to figure out?
 By the way, dmd compiles (and links) my file just fine if I declare (since
 it's not in Walter's windows.d) RegOpenKeyA as (void *,LPCSTR,PHKEY) or as
 (int,LPCSTR,PHKEY). why? are void* and int the same? (I know they're not,
 but still....)
ummm...Good question. They're both the same size. Maybe they just both show up as double words in the lib files rather than specific types? That doesn't seem right though. On a completely unrelated note. Why does Microsoft have to put reply and reply to group right next to eachother?
Mar 27 2003
parent reply "Matthew Wilson" <dmd synesis.com.au> writes:
void * is the same size as int. Both 32-bits. You're kind of tunnelling
through the type system, and it works because of the same size. To a
processor, there is no difference between void* and int32

"Jon Allen" <jallen minotstateu.edu> wrote in message
news:b60nlr$2jb$1 digitaldaemon.com...
 Of course!!!!!!!!!!!!!!!!!!!!!!!!! I had no idea it needed
 advapi32.lib....................
 I'm gonna shoot myself!!!!!!!!!!!
 (well, not so much)
 also, for some reason, besides src\phobos\windows.d, I have a really old
 Pavel's windows.d (more complete, though), and there's where I had all
those
 weird declarations.
 my God!!!!!!!!!! how can a human being be sooooooooooooooo stupid?
Heh, go figure. Why is it always the simplest possible problem that is always the hardest to figure out?
 By the way, dmd compiles (and links) my file just fine if I declare
(since
 it's not in Walter's windows.d) RegOpenKeyA as (void *,LPCSTR,PHKEY) or
as
 (int,LPCSTR,PHKEY). why? are void* and int the same? (I know they're
not,
 but still....)
ummm...Good question. They're both the same size. Maybe they just both show up as double words in the lib files rather than specific types? That doesn't seem right though. On a completely unrelated note. Why does Microsoft have to put reply and reply to group right next to eachother?
Mar 27 2003
parent reply "Jon Allen" <jallen minotstateu.edu> writes:
Do you know whether exported finction in libs (or dll's for that matter)
contain any type information besides just sizes?  It seems like they should
but it also seems like they don't.

"Matthew Wilson" <dmd synesis.com.au> wrote in message
news:b60upk$7p5$1 digitaldaemon.com...
 void * is the same size as int. Both 32-bits. You're kind of tunnelling
 through the type system, and it works because of the same size. To a
 processor, there is no difference between void* and int32

 "Jon Allen" <jallen minotstateu.edu> wrote in message
 news:b60nlr$2jb$1 digitaldaemon.com...
 Of course!!!!!!!!!!!!!!!!!!!!!!!!! I had no idea it needed
 advapi32.lib....................
 I'm gonna shoot myself!!!!!!!!!!!
 (well, not so much)
 also, for some reason, besides src\phobos\windows.d, I have a really
old
 Pavel's windows.d (more complete, though), and there's where I had all
those
 weird declarations.
 my God!!!!!!!!!! how can a human being be sooooooooooooooo stupid?
Heh, go figure. Why is it always the simplest possible problem that is always the hardest to figure out?
 By the way, dmd compiles (and links) my file just fine if I declare
(since
 it's not in Walter's windows.d) RegOpenKeyA as (void *,LPCSTR,PHKEY)
or
 as
 (int,LPCSTR,PHKEY). why? are void* and int the same? (I know they're
not,
 but still....)
ummm...Good question. They're both the same size. Maybe they just both show up as double words in the lib files rather than specific types?
That
 doesn't seem right though.


 On a completely unrelated note.  Why does Microsoft have to put reply
and
 reply to group right next to eachother?
Mar 28 2003
parent "Matthew Wilson" <dmd synesis.com.au> writes:
They don't. While this can be an opportunity for errors, it does also

to C DLL functions. By declaring the function signatures with differing, but
known (by me!) to be benignly equivalent, types, I can avoid a whole load of

but used judiciously it can be a nice thing.

"Jon Allen" <jallen minotstateu.edu> wrote in message
news:b6162e$de2$1 digitaldaemon.com...
 Do you know whether exported finction in libs (or dll's for that matter)
 contain any type information besides just sizes?  It seems like they
should
 but it also seems like they don't.

 "Matthew Wilson" <dmd synesis.com.au> wrote in message
 news:b60upk$7p5$1 digitaldaemon.com...
 void * is the same size as int. Both 32-bits. You're kind of tunnelling
 through the type system, and it works because of the same size. To a
 processor, there is no difference between void* and int32

 "Jon Allen" <jallen minotstateu.edu> wrote in message
 news:b60nlr$2jb$1 digitaldaemon.com...
 Of course!!!!!!!!!!!!!!!!!!!!!!!!! I had no idea it needed
 advapi32.lib....................
 I'm gonna shoot myself!!!!!!!!!!!
 (well, not so much)
 also, for some reason, besides src\phobos\windows.d, I have a really
old
 Pavel's windows.d (more complete, though), and there's where I had
all
 those
 weird declarations.
 my God!!!!!!!!!! how can a human being be sooooooooooooooo stupid?
Heh, go figure. Why is it always the simplest possible problem that
is
 always the hardest to figure out?

 By the way, dmd compiles (and links) my file just fine if I declare
(since
 it's not in Walter's windows.d) RegOpenKeyA as (void *,LPCSTR,PHKEY)
or
 as
 (int,LPCSTR,PHKEY). why? are void* and int the same? (I know they're
not,
 but still....)
ummm...Good question. They're both the same size. Maybe they just
both
 show up as double words in the lib files rather than specific types?
That
 doesn't seem right though.


 On a completely unrelated note.  Why does Microsoft have to put reply
and
 reply to group right next to eachother?
Mar 28 2003
prev sibling parent Burton Radons <loth users.sourceforge.net> writes:
Carlos Santander B. wrote:
 By the way, dmd compiles (and links) my file just fine if I declare (since
 it's not in Walter's windows.d) RegOpenKeyA as (void *,LPCSTR,PHKEY) or as
 (int,LPCSTR,PHKEY). why? are void* and int the same? (I know they're not,
 but still....)
The D calling convention has type information in the signatures so they can be differentiated, but the Windows calling convention has the stack size only, which is what the 12 at the end is indicating.
Mar 28 2003