OK. Please could you post the code?
I need to see what you've written so I can help you.
CString.format
heres the problem part.
global.h
wjen I hover over DLDorectory in debug mode, it tells me the value is "c:\documents and setting\..."
(... is me shorterning it)
if (RegOpenKeyEx(HKEY_LOCAL_MACHINE,_T("SOFTWARE\\Apocalypse Systems\\General"),0,KEY_SET_VALUE,&globals::hk)) { LPVOID msg; FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER|FORMAT_MESSAGE_FROM_SYSTEM,NULL,GetLastError(),MAKELANGID(LANG_NEUTRAL,SUBLANG_DEFAULT),(LPWSTR)&msg,0,NULL); MessageBox(NULL,(LPCTSTR)msg,_T("Error"),MB_OK|MB_ICONERROR); } int j = globals::DLDirectory.GetLength(); LPTSTR data = new TCHAR[1024]; data = globals::DLDirectory.GetBuffer(1024); // DLDirectory = "c:\documents and settings\ ..." data = "c:\documents a" globals::DLDirectory.ReleaseBuffer(); if (RegSetValueEx(globals::hk,_T("Download Folder"),0,REG_SZ,(LPBYTE)data,count)) { LPVOID msg; FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER|FORMAT_MESSAGE_FROM_SYSTEM,NULL,GetLastError(),MAKELANGID(LANG_NEUTRAL,SUBLANG_DEFAULT),(LPWSTR)&msg,0,NULL); MessageBox(NULL,(LPCTSTR)msg,_T("Error"),MB_OK|MB_ICONERROR); }}
global.h
#include <atlstr.h>#if !defined GLOBAL_H#define GLOBAL_Hclass globals{public: static char *URL[1]; static int current; static bool DLRequested[1]; static bool FolderChanged; static CString Folder; static CString DLDirectory; static CString TempDirectory; static CString EDFIDirectory; static CString NewFolder; static bool IsNewFolder; static DWORD AutoCreate; static DWORD Alarm; static DWORD balloon; static DWORD ExitComplete; static DWORD Minimize; static HKEY hk;};#endif
wjen I hover over DLDorectory in debug mode, it tells me the value is "c:\documents and setting\..."
(... is me shorterning it)
Ok, I think I may have a bodge that may work but I'm not sure. The only thing I can see that would cause your problem is that size difference between char and wchar_t. BYTE is actually char, and I doubt the registry functions will allow for this difference.
By the way I wouldn't allocate a new buffer for the CString, the class does it for you. Also there is no need for the ReleaseBuffer() call, thats only required if you modify the buffer.
I haven't tried this code out so I'm not sure if it will work but its worth a try eh? lol The reason I've added the sizeof(TCHAR) bit is to get the actual size of the string and not the length.
Hope this works :)
By the way I wouldn't allocate a new buffer for the CString, the class does it for you. Also there is no need for the ReleaseBuffer() call, thats only required if you modify the buffer.
int nCount = globals::DLDirectory.GetLength();LPTSTR lpszBuffer = globals::DLDirectory.GetBuffer(nCount);if (RegSetValueEx(globals::hk,_T("Download Folder"),0,REG_SZ,(LPBYTE)lpszBuffer,nCount * sizeof(TCHAR))){ LPTSTR lpszMsg; FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER|FORMAT_MESSAGE_FROM_SYSTEM,NULL,GetLastError(),MAKELANGID(LANG_NEUTRAL,SUBLANG_DEFAULT),lpszMsg,0,NULL); MessageBox(NULL,lpszMsg,_T("Error"),MB_OK|MB_ICONERROR);}
I haven't tried this code out so I'm not sure if it will work but its worth a try eh? lol The reason I've added the sizeof(TCHAR) bit is to get the actual size of the string and not the length.
Hope this works :)
Or you can just turn off unicode build mode (note that it's still supported, just that win32 functions will default to the ascii versions), as shown in my journal!!!!
Well yeah, but that would be the easy way out :P
Plus it sounds as if crazy_andy wants unicode, for whatever reason...
Plus it sounds as if crazy_andy wants unicode, for whatever reason...
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement