Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

REG_QWORD - RegSetValueEx

529 views
Skip to first unread message

hagen

unread,
Aug 30, 2004, 1:51:01 PM8/30/04
to
hi,

does s.o has an example, how to pass a REG_QWORD to the RegSetValueEx function?

For REG_DWORD sokmething like this works:

RegSetValueEx(
hKey,
lpValueName,
NULL,
REG_DWORD,
0x0000,
nSize
);


I tried

RegSetValueEx(
hKey,
lpValueName,
NULL,
REG_QWORD,
0x00000000,
nSize
);

but the resulting registry entry is not correct.

if I pass 0x0000000000000000 my application crashes with an exception error :(

thx & regards

hagen

hagen

unread,
Aug 30, 2004, 1:50:14 PM8/30/04
to

Igor Tandetnik

unread,
Aug 30, 2004, 2:04:36 PM8/30/04
to
"hagen" <h.mu...@substring.ch> wrote in message
news:1ff2226.04083...@posting.google.com

> does s.o has an example, how to pass a REG_QWORD to the RegSetValueEx
> function?
>
> For REG_DWORD sokmething like this works:
>
> RegSetValueEx(
> hKey,
> lpValueName,
> NULL,
> REG_DWORD,
> 0x0000,
> nSize
> );

This is wrong. The next to last parameter should be a pointer to a DWORD
variable holding the value, not the value itself. As in

DWORD value = 0;
RegSetValueEx(hKey, lpValueName, NULL,
REG_DWORD, (BYTE*)&value, sizeof(value));

REG_QWORD works the same way, only you pass a pointer to ULONGLONG as
the data.
--
With best wishes,
Igor Tandetnik

"For every complex problem, there is a solution that is simple, neat,
and wrong." H.L. Mencken


hagen

unread,
Aug 30, 2004, 11:17:27 PM8/30/04
to
"Igor Tandetnik" <itand...@mvps.org> wrote in message news:<ejZkbvr...@TK2MSFTNGP11.phx.gbl>...

> "hagen" <h.mu...@substring.ch> wrote in message
> news:1ff2226.04083...@posting.google.com
> > does s.o has an example, how to pass a REG_QWORD to the RegSetValueEx
> > function?
> >
> > For REG_DWORD sokmething like this works:
> >
> > RegSetValueEx(
> > hKey,
> > lpValueName,
> > NULL,
> > REG_DWORD,
> > 0x0000,
> > nSize
> > );
>
> This is wrong. The next to last parameter should be a pointer to a DWORD
> variable holding the value, not the value itself. As in
>
> DWORD value = 0;
> RegSetValueEx(hKey, lpValueName, NULL,
> REG_DWORD, (BYTE*)&value, sizeof(value));
>
> REG_QWORD works the same way, only you pass a pointer to ULONGLONG as
> the data.


Thanx for the ULONGLONG tip. It's working.
Hagen

hagen

unread,
Sep 1, 2004, 5:02:02 AM9/1/04
to
"Igor Tandetnik" <itand...@mvps.org> wrote in message news:<ejZkbvr...@TK2MSFTNGP11.phx.gbl>...
> "hagen" <h.mu...@substring.ch> wrote in message
> news:1ff2226.04083...@posting.google.com
> > does s.o has an example, how to pass a REG_QWORD to the RegSetValueEx
> > function?
> >
> > For REG_DWORD sokmething like this works:
> >
> > RegSetValueEx(
> > hKey,
> > lpValueName,
> > NULL,
> > REG_DWORD,
> > 0x0000,
> > nSize
> > );
>
> This is wrong. The next to last parameter should be a pointer to a DWORD
> variable holding the value, not the value itself. As in
>
> DWORD value = 0;
> RegSetValueEx(hKey, lpValueName, NULL,
> REG_DWORD, (BYTE*)&value, sizeof(value));
>
> REG_QWORD works the same way, only you pass a pointer to ULONGLONG as
> the data.


hi again,

I was to early happy:
passing a pointer to ULONGLONG yields a result like (see value for ExecTime):

[HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\System\Scripts\Startup\0\0]
"Script"="c:\\winnt\\perl\\bin\\perl.exe"
"Parameters"="c:\\winnt\\scripts\\foo.pl"
"ExecTime"=hex(b):00,00,00,00

But what I try to get is an entry like this:

[HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\System\Scripts\Startup\0\0]
"Script"="c:\\winnt\\perl\\bin\\perl.exe"
"Parameters"="c:\\winnt\\scripts\\foo.pl"
"ExecTime"=hex(b):00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00

Further ideas?
Hagen

Igor Tandetnik

unread,
Sep 1, 2004, 9:37:42 AM9/1/04
to
"hagen" <h.mu...@substring.ch> wrote in message
news:1ff2226.04090...@posting.google.com

> I was to early happy:
> passing a pointer to ULONGLONG yields a result like (see value for
> ExecTime):
>
>
[HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\System\Scripts\S
tartup\0\0]
> "Script"="c:\\winnt\\perl\\bin\\perl.exe"
> "Parameters"="c:\\winnt\\scripts\\foo.pl"
> "ExecTime"=hex(b):00,00,00,00

I've just tried it - works for me as expected. Make sure you pass the
correct data size in the last parameter.

hagen

unread,
Sep 1, 2004, 1:11:03 PM9/1/04
to
h.mu...@substring.ch (hagen) wrote in message news:<1ff2226.04090...@posting.google.com>...


I saw it doesn't matter: my startup script are working even the value
for ExecTime differs a bit from the value which occurs if the local
policy mmc snapin was used.

Tim Roberts

unread,
Sep 3, 2004, 12:39:37 AM9/3/04
to
h.mu...@substring.ch (hagen) wrote:
>
>But what I try to get is an entry like this:
>
>[HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\System\Scripts\Startup\0\0]
>"Script"="c:\\winnt\\perl\\bin\\perl.exe"
>"Parameters"="c:\\winnt\\scripts\\foo.pl"
>"ExecTime"=hex(b):00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00
>
>Further ideas?

That's a heck of a lot more than a quadword. You will need to use
REG_BINARY and specify a buffer that it 16 bytes long.
--
- Tim Roberts, ti...@probo.com
Providenza & Boekelheide, Inc

0 new messages