Linker requires main function only when using debug default libraries (Multi-threaded Debug) so you can just leave your empty main function - in release mode (Multi-threaded) linker will ignore it (you may even enclose it in #ifdef _DEBUG ... #endif block and it will work fine).
Oops, you right. I thought that _DLL is defined when I'm compiling DLL... But now I see that it is defined when CRT is linked as dynamic library.
I corrected sample in previous post.
VS 10 doesn't require main function stub (BTW as I can remember VS 9 shouldn't require it too...). But it requires it if I redefine entry point (unfortunately I don't know how to distinguish theese two cases using predefined macros).
In C usual WCHAR* is a PWideChar in Delphi - you need to assign to it address of some buffer before using.
Well, first of all you need to decide allocation type for s3 - static or dynamic. Then you may copy s1 to s3 using wcscpy and then append s2 to s3 using wcscat.
Please don't use wcscpy and wcscat, they do not check the length and will therefore cause a crash if the string is too long. Instead, please use wcslcpy and wcslcat from the cunicode.c file from my sample plugins. Here they are:
I think it would be easier to use lstrcpynW function - it appends NULL character even if iMaxLength is less than string length, and it is Windows API function so it doesn't require additional piece of code.
Although, is there list of WinAPI NTFS-related (directory creation, file info etc.), which support path about 32000 Unicode characters (begining from "\\?\") instead of 260 characters, defined by MAX_PATH?
#define MY_MAX_PATH 32768 //REAL NTFS MAX_PATH
#define UNC_PREFIX L"\\\\?\\"
BOOL my_CreateDirectoryW(
__in LPCWSTR lpPathName,
__in_opt LPSECURITY_ATTRIBUTES lpSecurityAttributes
)
{
WCHAR *tmpchr;
WCHAR tmpDir[MY_MAX_PATH];
wcscpy_s(tmpDir,MY_MAX_PATH,lpPathName);
WCHAR tmpUpDir[MY_MAX_PATH];
wcscpy_s(tmpUpDir,MY_MAX_PATH,lpPathName);
if (wcslen(wcsrchr(tmpUpDir,L'\\'))==1)
{
tmpchr=wcsrchr(tmpUpDir,L'\\');
*tmpchr=L'\0';
}
tmpchr=(WCHAR *)((DWORD)wcsrchr(tmpUpDir,L'\\')+sizeof(WCHAR)); //we need the last character
*tmpchr=L'\0';
if (!PathFileExistsW(tmpUpDir)) //there is no upper directory, try to create in
{
if ((wcscmp(tmpUpDir,tmpDir)==0)||(wcscmp(tmpUpDir,UNC_PREFIX)==0)) //there cant't upper directory
{
SetLastError(ERROR_PATH_NOT_FOUND);
return FALSE;
}
else //there can be
{
return my_CreateDirectoryW(tmpUpDir,lpSecurityAttributes);
}
}
else
{
return CreateDirectoryW(tmpDir,lpSecurityAttributes); //hl may be created only in existing directory
}
}