Computer Help and Spyware Removal Computer Help and Spyware Removal Computer Help and Spyware Removal Computer Help Forums Windows Startup Programs Database Virus, Spyware, and Malware Removal Guides Computer Tutorials Uninstall Database File Database Computer Glossary Computer Resources
 

Welcome Guest ( Log In | Click here to Register a free account now! )



Register a free account to unlock additional features at BleepingComputer.com
Welcome to Bleeping Computer, a free community where people like yourself come together to discuss and learn how to use their computers. Using the site is easy and fun. As a guest, you can browse and view the various discussions in the forums, but can not create a new topic or reply to an existing one unless you are logged in. Other benefits of registering an account are subscribing to topics and forums, creating a blog, and having no ads shown anywhere on the site.
Click here to Register a free account now! or read our Welcome Guide to learn how to use this site.

2 Pages V  < 1 2  
Reply to this topicStart new topic
> C++ register string value error, Wrong data value
Billy O'Neal
post May 12 2009, 02:53 PM
Post #16


Look buddy -- I'm an Engineer
******

Group: HJT Team Coach
Posts: 8,509
Joined: 17-January 08
From: Northfield, Ohio
Member No.: 184,215



That's what needed fixed, but that's not the question I asked ;)

Keep in mind that path is a pointer... not an array object. Where is the memory that contains the string L"C:\\WINDOWS\\system32\\test.exe"?

Billy3


--------------------
Go to the top of the page
 
+Quote Post
KaZu
post May 13 2009, 03:50 AM
Post #17


Member
**

Group: Members
Posts: 16
Joined: 11-May 09
Member No.: 330,588



Ah yes smile.gif
KaZu
Go to the top of the page
 
+Quote Post
Billy O'Neal
post May 13 2009, 09:47 PM
Post #18


Look buddy -- I'm an Engineer
******

Group: HJT Team Coach
Posts: 8,509
Joined: 17-January 08
From: Northfield, Ohio
Member No.: 184,215



Err... What?

Billy3


--------------------
Go to the top of the page
 
+Quote Post
KaZu
post May 14 2009, 09:28 AM
Post #19


Member
**

Group: Members
Posts: 16
Joined: 11-May 09
Member No.: 330,588



Aha didnt see your question, just the first thing about the pointer..
As I have been learned. Path is a pointer and its in the new wchar_t[80] memory the String is allocated. Do I got it right?
KaZu
Go to the top of the page
 
+Quote Post
Billy O'Neal
post May 14 2009, 03:11 PM
Post #20


Look buddy -- I'm an Engineer
******

Group: HJT Team Coach
Posts: 8,509
Joined: 17-January 08
From: Northfield, Ohio
Member No.: 184,215



Heehe... but you never allocated that string, did you? tongue.gif

Billy3


--------------------
Go to the top of the page
 
+Quote Post
KaZu
post May 14 2009, 03:27 PM
Post #21


Member
**

Group: Members
Posts: 16
Joined: 11-May 09
Member No.: 330,588



hehe no tongue.gif
KaZu
Go to the top of the page
 
+Quote Post
Billy O'Neal
post May 14 2009, 03:29 PM
Post #22


Look buddy -- I'm an Engineer
******

Group: HJT Team Coach
Posts: 8,509
Joined: 17-January 08
From: Northfield, Ohio
Member No.: 184,215



What operation does the = actually perform here?

Reason I'm asking here is because this is one aspect where C is different from pretty much every other language.....

Billy3


--------------------
Go to the top of the page
 
+Quote Post
KaZu
post May 15 2009, 02:15 AM
Post #23


Member
**

Group: Members
Posts: 16
Joined: 11-May 09
Member No.: 330,588



Hm I guess that = says that Path points on a new memoryspace?
KaZu
Go to the top of the page
 
+Quote Post
KaZu
post May 17 2009, 08:28 AM
Post #24


Member
**

Group: Members
Posts: 16
Joined: 11-May 09
Member No.: 330,588



One more question. Would this code work on vista?
KaZu
Go to the top of the page
 
+Quote Post
Billy O'Neal
post May 17 2009, 05:23 PM
Post #25


Look buddy -- I'm an Engineer
******

Group: HJT Team Coach
Posts: 8,509
Joined: 17-January 08
From: Northfield, Ohio
Member No.: 184,215



Hello smile.gif

QUOTE
Hm I guess that = says that Path points on a new memoryspace?

Nope. When windows starts your EXE file, it copies the executable into memory space. The = operation simply assigns the address of the executable's memory mapped string to the pointer.

Unlike languages such as C# or Java, strings in C are not objects. The = operator does not work with them. Neither do + or anything like somestring.substring as they do in other languages.

C strings are raw memory arrays. All you can do with them is exactly how you might act on an array. If you want to do simple operations such as copy, concat, or anything like that, you need to use library functions.

Copy: strcpy(copyTo, copyFrom);
Concat: strcat(addTo, addFrom);
etc.
A list of such library functions can be found here: http://www.cplusplus.com/reference/clibrary/cstring/
They are all in "string.h" (for C) or <cstring> (for C++).

The final thing with C strings is that you need to ensure enough RAM is allocated at the target location. These calls will NOT fail or cause any error in the event you overwrite past the end of the array. C has no bounds checking on arrays, and if you overwrite one you can crash the operating system, or possibly overwrite part of your progam's code (A "buffer overrun").

Be careful working with C strings. For a safer alternative, if you have access to C++, you can use C++'s std::basic_string<> type.

QUOTE
One more question. Would this code work on vista?

Not sure. However see this link on MSDN:
http://msdn.microsoft.com/en-us/library/ms724842(VS.85).aspx
QUOTE
Note This function is provided only for compatibility with 16-bit versions of Windows. Applications should use the RegCreateKeyEx function.


Hope that helps,
Billy3


--------------------
Go to the top of the page
 
+Quote Post
KaZu
post May 18 2009, 03:31 AM
Post #26


Member
**

Group: Members
Posts: 16
Joined: 11-May 09
Member No.: 330,588



Ah thanks for the information. I used c++ for this code so should not be that hard :-)
KaZu
Go to the top of the page
 
+Quote Post
KaZu
post May 18 2009, 05:42 AM
Post #27


Member
**

Group: Members
Posts: 16
Joined: 11-May 09
Member No.: 330,588



Billy can I ask you another question instead of creating a new topic?
The question is about creating a setup wizard in c++. I have used it now to my project and made the 5 steps, but how do I compile it and make it to create a install file?
KaZu

Nvm I solved the problem smile.gif

This post has been edited by KaZu: May 18 2009, 08:00 AM
Go to the top of the page
 
+Quote Post
KaZu
post May 20 2009, 09:48 AM
Post #28


Member
**

Group: Members
Posts: 16
Joined: 11-May 09
Member No.: 330,588



Yes it´s :-) Would be great for others to have a article about this. It will mostly solve all the problem
KaZu

This post has been edited by KaZu: May 20 2009, 10:01 AM
Go to the top of the page
 
+Quote Post

2 Pages V  < 1 2
Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 



Lo-Fi Version Time is now: 8th November 2009 - 05:43 AM


Advertise   |   About Us   |   Terms of Use   |   Privacy Policy   |   Contact Us   |   Site Map   |   Chat   |   Tutorials   |   Uninstall List
Discussion Forums   |   The Computer Glossary   |   Resources   |   RSS Feeds   |   Startups   |   The File Database   |   Virus Removal Guides

© 2003-2009 All Rights Reserved Bleeping Computer LLC.