Returning a char array this way is tricky. Either you have to allocate the memory inside the function and free it outside (which is very ugly), or you can pass the pointer as a parameter of the function and manipulate its content. Anyway, it is much better to use the std::string (from the Standard Template Library) for which you don't need to care about memory usage.
Note that both of those can be sketchy if the returning function is allocating memory on the heap and expecting you to handle cleanup (very poor design, but not too uncommon, sadly). Just keep that in mind when dealing with this kind of thing.
If you decide to become a software engineer, you are signing up to have a 1/2" piece of silicon tell you exactly how stupid you really are for 8 hours a day, 5 days a week
MSDN document says.
Maximum Path Length
In the Windows API, the maximum length for a path is MAX_PATH, which is defined as 260 characters. A path is structured in the following order: drive letter, colon, backslash, components separated by backslashes, and a null-terminating character, for example, the maximum path on the D drive is D:\<256 chars>NUL.
The Unicode versions of several functions permit a maximum path length of approximately 32,000 characters composed of components up to 255 characters in length. To specify that kind of path, use the "\\?\" prefix.
How do we create a file with path name more 260 characters ?.
i want to know that CTTListBox is not in the listbox type as i want to declare a variable of this type.
when i decalare this directly or by changing CListBox type then it gives error
plz tell me how can i use this
I am having a problem in my application, what I am doing is:
Calling a function SaveKeys(TCHAR *) within a loop and this function save the specified registry key to a .reg file,
for this using CreateProcess( ) for calling regedit.exe from command line and WaitForSingleObject( ) function.
code looks like this
for (int i = 0; i <10;i++)<br/>
// some code here<br/>
SaveKeys(cRegistryKey ); // for specified Registry Key<br/>
void MyClass::SaveKeys(TCHAR *cRegistryKey)<br/>
CreateProcess(NULL, cCommand,NULL,NULL,FALSE,CREATE_DEFAULT_ERROR_MODE|CREATE_SUSPENDED,NULL, NULL, &StartupInfo, &ProcessInformation);<br/>
WaitForSingleObject( ProcessInformation.hProcess, INFINITE );<br/><br/>
//e.g. Here cCommand = regedit /e C:\File.reg HKEY_CURRENT_USER\MyKey<br/>
Now what is my problem is that here WaitForSingleObject( ) function is not working. and only a single reg file is created.
and when use Sleep(1000) then all the 10 reg file are created.
So please tell me that how should I overcome this problem.