Conversion 
Author Message
 Conversion

I'm writing a program that reads a value (file path) of the registry, adds a
string ( "\\file.ext" ) to that value and copies that file.
How can I copy the value in 'keyVal' to 'File' and adds "\\file.ext" to
'File'?
The program can only run with the standard Windows 98 SE dll's. So I can't
use CString, can I?

This is what I have:

DWORD TheLength;
LPTSTR keyVal = new TCHAR[100];
CRegKey Registry;
LPCTSTR File;
TheLength = 100; keyVal[0] = '\0';

Register.Open(HKEY_LOCAL_MACHINE,"System\\CurrentControlSet\\Control\\Update
");
Register.QueryValue(keyVal,"NetworkPath",&TheLength);
Register.Close();

// the problem     File=keyVal+"\\file.ext"

BOOL bFail=0; CopyFile(File,"a:\\file.ext",bFail);

Jochem



Thu, 27 Jun 2002 03:00:00 GMT  
 Conversion
There are two options:

Use the old C style strings:
...
strcat( keyval, \\file.ext);

Or use the STL string type:
...
std::string extstr(keyval);
extstr += \\file.ext;

Sytse.

Quote:
>// the problem     File=keyVal+"\\file.ext"



Thu, 27 Jun 2002 03:00:00 GMT  
 Conversion

Quote:

>I'm writing a program that reads a value (file path) of the registry, adds
a
>string ( "\\file.ext" ) to that value and copies that file.
>How can I copy the value in 'keyVal' to 'File' and adds "\\file.ext" to
>'File'?
>The program can only run with the standard Windows 98 SE dll's. So I can't
>use CString, can I?

I'm assuming you mean you don't want to install any other DLLs.

If that is the case, you certainly can use CStrings; you can use
the version of MFC whose DLLs are part of the SE install (not
sure which that would be; probably version 6), or link MFC
statically.

Quote:
>DWORD TheLength;
>LPTSTR keyVal = new TCHAR[100];
>LPCTSTR File;
>// the problem     File=keyVal+"\\file.ext"

Yep; that's not a valid operation on a character array.

By the way, File is an uninitialized pointer; try TCHAR
File[MAX_PATH] instead, or allocate dynamically
with operator new, as you did with keyVal.

MAX_PATH is #defined as the maximum number of
characters in a standard file path.

Try either strcat() or sprintf() in the standard library.

    sprintf(File, ""%s%s", keyVal, "\\file.ext");



Thu, 27 Jun 2002 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. C to Pascal Conversion (Was: Pascal to C Conversion)

2. String conversion and double-to-string conversion

3. String conversion and double-to-string conversion

4. String conversion and double-to-string conversion

5. Java Language Conversion Assistant

6. String to byte array conversion and back....

7. conversion...again

8. a function-style conversion to a built-in type can only take one argument

9. Conversion from VC 7.0 to 7.1

10. Type conversion question

11. Fastest Conversion Method?

12. Unmanaged dll conversion of reference argument from msvc++

 

 
Powered by phpBB® Forum Software