hi everyone
I programm an ISAPI extension with embedded Visual C++ for a Windows
CE device.
I try to write the network settings to the registry.
I am able to write the IpAdress to the registry, but when I compare my
registry entry and the one made with the Windows CE settings, I miss
some hex chars:
The Way I write my registry entry:
LONG iSuccess = RegCreateKeyEx( HKEY_LOCAL_MACHINE, lpstrKey, 0L,NULL,
REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &hKey,lpdwDisp);
if(iSuccess == ERROR_SUCCESS) {
lpstrSubkey = L"IpAddress";
MultiByteToWideChar(CP_ACP, 0, NetValueArray[queryCounter], -1,
lpstrSubkeyValue, sizeof(lpstrSubkeyValue));
/**** WRITE A HEX VALUE IN REGISTRY ****/
DWORD dwDispHex = 0;
LPDWORD lpdwDispHex = &dwDispHex;
iSuccess = RegCreateKeyEx( HKEY_LOCAL_MACHINE, lpstrKey,
0L,NULL, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL,
&hKey,lpdwDispHex);
if(iSuccess == ERROR_SUCCESS)
{
RegSetValueEx(hKey, lpstrSubkey, 0, REG_MULTI_SZ,
(LPBYTE)lpstrSubkeyValue, strlen(NetValueArray[queryCounter])*2);
}
}
This results in this Registry Entry:
"IpAddress"=hex(7):\
31,32,33,2e,31,32,33,2e,31,32,33,2e,31,32,33
The same Registry Entry made in the Windows CE settings looks like
that:
"IpAddress"=hex(7):\
31,32,33,2e,31,32,33,2e,31,32,33,2e,31,32,33,00,00
What kind of hexchar is 00?
And how can I add this to my registry entry?
Greetings
Thomas 8 2869
On 2007-08-14 10:40, Kniffel wrote:
hi everyone
I programm an ISAPI extension with embedded Visual C++ for a Windows
CE device.
I try to write the network settings to the registry.
I am able to write the IpAdress to the registry, but when I compare my
registry entry and the one made with the Windows CE settings, I miss
some hex chars:
The Way I write my registry entry:
LONG iSuccess = RegCreateKeyEx( HKEY_LOCAL_MACHINE, lpstrKey, 0L,NULL,
REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &hKey,lpdwDisp);
if(iSuccess == ERROR_SUCCESS) {
lpstrSubkey = L"IpAddress";
MultiByteToWideChar(CP_ACP, 0, NetValueArray[queryCounter], -1,
lpstrSubkeyValue, sizeof(lpstrSubkeyValue));
/**** WRITE A HEX VALUE IN REGISTRY ****/
DWORD dwDispHex = 0;
LPDWORD lpdwDispHex = &dwDispHex;
iSuccess = RegCreateKeyEx( HKEY_LOCAL_MACHINE, lpstrKey,
0L,NULL, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL,
&hKey,lpdwDispHex);
if(iSuccess == ERROR_SUCCESS)
{
RegSetValueEx(hKey, lpstrSubkey, 0, REG_MULTI_SZ,
(LPBYTE)lpstrSubkeyValue, strlen(NetValueArray[queryCounter])*2);
}
}
This results in this Registry Entry:
"IpAddress"=hex(7):\
31,32,33,2e,31,32,33,2e,31,32,33,2e,31,32,33
The same Registry Entry made in the Windows CE settings looks like
that:
"IpAddress"=hex(7):\
31,32,33,2e,31,32,33,2e,31,32,33,2e,31,32,33,00,00
What kind of hexchar is 00?
00 is 00 is 0 is 0x0.
And how can I add this to my registry entry?
Sorry, but this is off-topic in here, this group is for discussing the
C++ language as defined by the standard, third party libraries should be
discussed in their own groups. Try to post in either
comp.os.ms-windows.programmer.win32 or one of the microsoft.public.*
groups to get in contact with the windows experts.
--
Erik Wikström
Ok
thanks
i will try it then in a other group...
Hi!
Apart from the offtopic issue I spotted something which might be a bug.
Kniffel schrieb:
MultiByteToWideChar(CP_ACP, 0, NetValueArray[queryCounter], -1,
lpstrSubkeyValue, sizeof(lpstrSubkeyValue));
If "lpstrSubkeyValue" is an array, forget my post.
I guess "lpstrSubkeyValue" is a mere pointer (to wide chars). Thus
"sizeof(lpstrSubkeyValue)" will probably return 4. Demonstration:
char* lpstrFoo = "Foobarbaz";
std::cout << sizeof(lpstrFoo); //propably prints "4"
lpstrFoo[2] = 'A'; //not allowed, undefined behaviour
Frank
On 14 Aug., 11:11, Frank Birbacher <bloodymir.c...@gmx.netwrote:
Hi!
Apart from the offtopic issue I spotted something which might be a bug.
Kniffel schrieb:
MultiByteToWideChar(CP_ACP, 0, NetValueArray[queryCounter], -1,
lpstrSubkeyValue, sizeof(lpstrSubkeyValue));
If "lpstrSubkeyValue" is an array, forget my post.
I guess "lpstrSubkeyValue" is a mere pointer (to wide chars). Thus
"sizeof(lpstrSubkeyValue)" will probably return 4. Demonstration:
char* lpstrFoo = "Foobarbaz";
std::cout << sizeof(lpstrFoo); //propably prints "4"
lpstrFoo[2] = 'A'; //not allowed, undefined behaviour
Frank
Yes it returns 4.
The var is defined like that: WCHAR lpstrSubkeyValue[MAX_PATH+1];
How i get the size I should insert here?
Hi!
Kniffel schrieb:
The var is defined like that: WCHAR lpstrSubkeyValue[MAX_PATH+1];
How i get the size I should insert here?
Here sizeof(lpstrSubkeyValue) should not return 4. It should return the
size in bytes (actually the unit is sizeof(char), which is 1 on windows)
of the array. To get the number of elements which you need to pass to
that funtion you need to divide this by the size of a single element:
const DWORD sizeOfSubkeyValue = sizeof(lpstrSubkeyValue) /
sizeof(*lpstrSubkeyValue);
Here "*lpstrSubkeyValue" is the first element of the array. Now just
pass sizeOfSubkeyValue to the function.
Frank
const DWORD sizeOfSubkeyValue = sizeof(lpstrSubkeyValue) /
sizeof(*lpstrSubkeyValue);
This gives me a size of 510... this is way to much. And my registry
value contains things I don´t want.
My calculation gives the correct size, I added "+1" since the first
post:
(strlen(NetValueArray[queryCounter])*2)+1
The var is defined like that: WCHAR lpstrSubkeyValue[MAX_PATH+1];
>
If you're going to use unreadable Microsoft Hungarian prefixes, at least
use them correctly, please.
You're not declaring "long pointer to string", lpstr.
Even better, get rid of that Hungarian notation.
You mean to just write "WCHAR SubkeyValue[MAX_PATH+1];"?
Hi!
Kniffel schrieb:
>const DWORD sizeOfSubkeyValue = sizeof(lpstrSubkeyValue) / sizeof(*lpstrSubkeyValue);
This gives me a size of 510...
Probably because MAX_PATH is that large.
Frank This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: benjamin schollnick |
last post by:
Folks,
I am having difficulty with *reading* the registry from a remote Windows
box...
1) I need to impersonate a different user name & password, then the
user I
am currently logged in as....
|
by: DC Gringo |
last post by:
I have some code that writes log entries upon errors in an VB.NET web app.
I can write the Message but in the log, preceding my message is the
following:
Description:
The description for...
|
by: firenet |
last post by:
Came in one morning and found that the following message appeared only on
running Access 2000, then the program shuts down, all other office 2000
applications work fine.
"Required registry...
|
by: caldera |
last post by:
Hi,
I write a windows service. In that service I create a new subkey for registry. But service
install is call CreateSubKey() the program throw an exception to the event log said that
Cannot write...
|
by: Dan Sikorsky |
last post by:
Should application data be read and written to the Registry to persist
state, or should the App.config file be used?
If the Registry should be used, what .NET class reads and writes the...
|
by: Chakkaradeep |
last post by:
Hi all,
in my service i added my Registry Programming code,am facing with a problem
which am not able to rectify it..the problem is , in the service, the program
gets hanged and doesnt move...
|
by: CMG |
last post by:
I am writing a little code to associate an extention with
my program. And as far as i can see, i need to do the
following:
Public Function associatefile(ByVal
FILE_EXTENTION_TO_ASSOCIATE As...
|
by: nbs.tag |
last post by:
hey guys heres my question. I was told by a little birdie that .net 2.0
has the ability to read a connection string directly from a registry
key. so in the registry key a string value of say :...
|
by: Michael Fay in SB |
last post by:
A month ago I posted:
"I built my application with Access 2003 and made a distribution using
the Microsoft Office Access 2003 Developer Extensions.
(I also install Jet 8 as a follow-on action at...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
| | |