-
Notifications
You must be signed in to change notification settings - Fork 31
Description
There are too many potential coding errors in source code
for example:
https://github.com/end2endzone/ShellAnything/blob/master/src/Win32Clipboard.cpp#L42
static const UINT gFormatDescriptorBinary = RegisterClipboardFormat("Binary");
static const UINT gFormatDescriptorDropEffect = RegisterClipboardFormat("Preferred DropEffect");it only work right when not define UNICODE. And RegisterClipboardFormatA will convert "Binary" to L"Binary", then call RegisterClipboardFormatW.
To improve compatibility, should write like RegisterClipboardFormatA("Binary"), or RegisterClipboardFormatW(L"Binary"),
or more appropriate: RegisterClipboardFormat(TEXT"Binary"))
I tried to modify a part of the code, but I found that this caused coding confusion in the code.
So I recommend using TCHAR instead of char, _stprintf_s instead of sprintf_s, TEXT("bala") instead of "bala"
#ifdef UNICODE
#define tstring std::wstring
#else
#define tstring std::string
#endifor more cpp style
typedef basic_string<TCHAR, char_traits<TCHAR>, allocator<TCHAR> > tstring;instead of std::string
(ref: https://stackoverflow.com/questions/36197514/what-is-the-macro-for-stdstring-stdwstring-in-vc)
And define UNICODE and _UNICODE