ImageMagicObject - non-ASCII characters
Posted: 2009-02-18T13:39:02-07:00
Hello everyone.
Here is my patch of OLE Automation wrapper of ImageMagick (ATL7 version).
ImageMagickObject is a fine simple wrapper but I cannot open any graphics file whitch name contains any non-ASCII character such as zażółć_gęślą_jaźń.jpg.
Additionaly I cannot render any text with non-ASCII (polish) characters.
The solution seems simple: instead of converting parameter strings from UTF-16 (all OLE Automation strings) to ANSI use UTF-16 to UTF-8 conversion. It seems that ImageMagic uses UTF-8 encoded strings internally.
Additionaly I decided to remove all ATL3 string conversion macros (USING_CONVERSION macro etc.) to new ATL7 class/macros.
I also removed usage of STL library (string class) and use CStringA and CStringW classes instead.
Additionaly code cleanup was performed - many unused macros,variables and funcions were removed.
I'm using VC++ 2005 and VC++ 2008.
Previous versions may not work.
Command line tools such ach convert.exe (Windows version) still have problems with non-ASII characters.
Because I cannot attach file to message here it is:
Here is my patch of OLE Automation wrapper of ImageMagick (ATL7 version).
ImageMagickObject is a fine simple wrapper but I cannot open any graphics file whitch name contains any non-ASCII character such as zażółć_gęślą_jaźń.jpg.
Additionaly I cannot render any text with non-ASCII (polish) characters.
The solution seems simple: instead of converting parameter strings from UTF-16 (all OLE Automation strings) to ANSI use UTF-16 to UTF-8 conversion. It seems that ImageMagic uses UTF-8 encoded strings internally.
Additionaly I decided to remove all ATL3 string conversion macros (USING_CONVERSION macro etc.) to new ATL7 class/macros.
I also removed usage of STL library (string class) and use CStringA and CStringW classes instead.
Additionaly code cleanup was performed - many unused macros,variables and funcions were removed.
I'm using VC++ 2005 and VC++ 2008.
Previous versions may not work.
Command line tools such ach convert.exe (Windows version) still have problems with non-ASII characters.
Because I cannot attach file to message here it is:
Code: Select all
Index: ImageMagickObject.cpp
===================================================================
--- ImageMagickObject.cpp (revision 14073)
+++ ImageMagickObject.cpp (working copy)
@@ -117,7 +117,7 @@
// MagickImage
[
coclass,
- threading("both"),
+ threading(both),
support_error_info("IMagickImage"),
vi_progid("ImageMagickObject.MagickImage"),
progid("ImageMagickObject.MagickImage.1"),
@@ -144,6 +144,9 @@
"MagickImage constructor");
m_bOnStartPageCalled = FALSE;
}
+
+private:
+
HRESULT TestHarness(SAFEARRAY **pArrayVar, VARIANT *pVar);
HRESULT Compare(SAFEARRAY **pArrayVar, VARIANT *pVar);
HRESULT Composite(SAFEARRAY **pArrayVar, VARIANT *pVar);
@@ -158,23 +161,26 @@
HRESULT Perform(MagickLib::MagickBooleanType (*func)(MagickLib::ImageInfo *image_info,
const int argc,char **argv,char **text,MagickLib::ExceptionInfo *exception),
SAFEARRAY **pArrayVar,VARIANT *pVar2,MagickLib::ExceptionInfo *exception);
+
private:
+
char **m_argv;
- char **m_argv_t;
int m_argc;
int m_argvIndex;
-public:
+
+
HRESULT AllocateArgs(int iArgs);
HRESULT ReAllocateArgs(int iArgs);
void DeleteArgs(void);
char **GetArgv(void);
- char **GetArgvT(void);
int GetArgc(void);
void EmptyArgs(void);
- //HRESULT AddArgs(VARIANTARG *arg);
- HRESULT AddArgs(BSTR arg);
- HRESULT AddArgs(LPTSTR arg);
+ HRESULT AddArgs(LPCWSTR);
+ HRESULT AddArgs(LPCSTR);
+
+ private:
+
static void warninghandler(const MagickLib::ExceptionType warning,const char *message,
const char *qualifier);
@@ -184,7 +190,9 @@
static void fatalerrorhandler(const MagickLib::ExceptionType error,const char *message,
const char *qualifier);
- void CheckAndReportError(MagickImageError &error, HRESULT &hr, const char *program);
+ static void CheckAndReportError(MagickImageError &error, HRESULT &hr, const char *program);
+
+ public:
DECLARE_PROTECT_FINAL_CONSTRUCT()
HRESULT FinalConstruct()
@@ -233,7 +241,7 @@
CComPtr<IObjectContext> m_spObjectContext;
};
-static char *translate_exception(DWORD code)
+static const char *translate_exception(DWORD code)
{
switch (code)
{
@@ -286,21 +294,6 @@
}
}
-static LPTSTR StrChr(LPTSTR lpsz, TCHAR ch)
-{
- LPTSTR p = NULL;
- while (*lpsz)
- {
- if (*lpsz == ch)
- {
- p = lpsz;
- break;
- }
- lpsz = CharNext(lpsz);
- }
- return p;
-}
-
const char *objName = "ImageMagickObject";
#define ThrowPerformException(exception,code,reason,description) \
@@ -347,8 +340,6 @@
STDMETHODIMP MagickImage::get_Item(VARIANT varIndex, VARIANT *pVal)
{
- USES_CONVERSION;
-
HRESULT hr = E_INVALIDARG;
VARIANTARG *pvarIndex = &varIndex;
VARTYPE vt = V_VT(pvarIndex);
@@ -364,10 +355,9 @@
return hr;
if ((vt & ~VT_BYREF) == VT_BSTR)
{
- LPTSTR lpszNext;
- LPTSTR lpszVal = W2T(V_BSTR(pvarIndex));
+ CW2A szVal( V_BSTR(pvarIndex) );
var = _T("");
- if (lpszVal)
+ if (szVal)
{
MagickLib::Image
*image;
@@ -380,15 +370,17 @@
long
id;
+
+ LPSTR lpszNext;
- lpszNext = StrChr(lpszVal, _T('.'));
- if (lpszNext == NULL)
- lpszNext = _T("%w,%h,%m");
+ lpszNext = StrChr(szVal, '.');
+ if (lpszNext == NULL)
+ lpszNext = "%w,%h,%m";
else
- *lpszNext++ = _T('\0');
+ *lpszNext++ = '\0';
// lookup the registry id using token and pass the image in
MagickLib::GetExceptionInfo(&exception);
- image=MagickLib::GetImageFromMagickRegistry(lpszVal, &id, &exception);
+ image=MagickLib::GetImageFromMagickRegistry(szVal, &id, &exception);
if (image != (MagickLib::Image *) NULL)
{
TCHAR *text;
@@ -506,8 +498,6 @@
STDMETHODIMP MagickImage::Remove(VARIANT varIndex)
{
- USES_CONVERSION;
-
HRESULT hr = E_INVALIDARG;
VARIANTARG *pvarIndex = &varIndex;
VARTYPE vt = V_VT(pvarIndex);
@@ -526,10 +516,9 @@
if (!V_ISBYREF(pvarIndex))
{
CComVariant var;
- LPTSTR lpszNext;
- LPTSTR lpszVal = W2T(V_BSTR(pvarIndex));
var = _T("");
- if (lpszVal)
+ CW2A szVal( V_BSTR(pvarIndex) );
+ if (szVal)
{
MagickLib::Image
*image;
@@ -539,15 +528,18 @@
long
id;
+
+ LPTSTR
+ lpszNext;
- lpszNext = StrChr(lpszVal, _T('.'));
+ lpszNext = StrChr(szVal, '.');
if (lpszNext == NULL)
- lpszNext = _T("%w,%h,%m");
+ lpszNext = "%w,%h,%m";
else
- *lpszNext++ = _T('\0');
+ *lpszNext++ = '\0';
// lookup the registry id using token and pass the image in
MagickLib::GetExceptionInfo(&exception);
- image=MagickLib::GetImageFromMagickRegistry(lpszVal, &id, &exception);
+ image=MagickLib::GetImageFromMagickRegistry(szVal, &id, &exception);
if (image != (MagickLib::Image *) NULL)
{
MagickLib::DestroyImageList(image);
@@ -765,28 +757,17 @@
// is the way that VB does it.
LPCWSTR pReturnBuffer = NULL;
long size = SafeArraySize(psa);
- long sizeneeded;
- char *ptrANSI;
hr = SafeArrayAccessData(psa, (void**)&pReturnBuffer);
if(SUCCEEDED(hr))
{
- sizeneeded = WideCharToMultiByte(
- CP_ACP, 0, pReturnBuffer, size/2, (LPSTR)NULL, 0, NULL, NULL);
- if (sizeneeded)
- {
- ptrANSI = new char [sizeneeded + 1];
- WideCharToMultiByte(
- CP_ACP, 0, pReturnBuffer, size, (LPSTR)ptrANSI, sizeneeded, NULL, NULL);
- ptrANSI[sizeneeded]='\0';
- hr = SafeArrayUnaccessData(psa);
- SafeArrayDestroy(psa);
-
- SAFEARRAY* pSafeArray = SafeArrayCreateVector(VT_UI1,0,0);
- wsprintf(sz, _T("xtrnarray:0x%lx,%s"),
- (unsigned long)(pSafeArray),ptrANSI);
- hr = AddArgs(sz);
- if (ptrANSI)
- delete ptrANSI;
+ CStringW ws( pReturnBuffer, size );
+ hr = SafeArrayUnaccessData(psa);
+ SafeArrayDestroy(psa);
+
+ SAFEARRAY* pSafeArray = SafeArrayCreateVector(VT_UI1,0,0);
+ wsprintf(sz, _T("xtrnarray:0x%lx,%ws"),
+ (unsigned long)(pSafeArray),(LPCWSTR)ws);
+ hr = AddArgs( sz );
if (V_ISBYREF(pvarIndex))
{
V_VT(pvarIndex) = VT_ARRAY | VT_UI1 | VT_BYREF;
@@ -797,12 +778,7 @@
V_VT(pvarIndex) = VT_ARRAY | VT_UI1;
V_ARRAY(pvarIndex) = pSafeArray;
}
- }
- else
- {
- ThrowPerformException(exception,MagickLib::ErrorException,
- "Perform","Output array for blob did not specify image format");
- }
+
}
else
{
@@ -1022,7 +998,6 @@
void MagickImage::CheckAndReportError(MagickImageError &error, HRESULT &hr, const char *program)
{
- USES_CONVERSION;
char message_text[MaxTextExtent];
if (FAILED(hr))
@@ -1062,7 +1037,8 @@
#ifdef _DEBUG
//DebugBreak();
#endif
- Error(A2W(message_text), __uuidof(IMagickImage), hr);
+ CA2WEX<MaxTextExtent> wsMessageText( message_text);
+ Error( wsMessageText, __uuidof(IMagickImage), hr);
}
MagickLib::DestroyExceptionInfo(&error.exception);
}
@@ -1355,7 +1331,7 @@
return hr;
}
-HRESULT MagickImage::AddArgs(BSTR widestr)
+HRESULT MagickImage::AddArgs(LPCWSTR widestr)
{
HRESULT hr = E_OUTOFMEMORY;
@@ -1364,11 +1340,12 @@
hr = S_OK;
- MAKE_ANSIPTR_FROMWIDE(ptrANSI, widestr);
- m_argv[m_argvIndex++] = ptrANSI;
+ CW2A sArgUTF8( widestr, CP_UTF8 );
+ m_argv[m_argvIndex++] = strdup( sArgUTF8 );
+ CW2A sArgANSI( widestr );
(void) MagickLib::LogMagickEvent(MagickLib::ResourceEvent,GetMagickModule(),
- "arg: %s",ptrANSI);
+ "arg: %s", (LPSTR)sArgANSI );
if (m_argvIndex >= m_argc)
hr = ReAllocateArgs( nDefaultArgumentSize );
@@ -1376,7 +1353,7 @@
return hr;
}
-HRESULT MagickImage::AddArgs(LPTSTR lpstr)
+HRESULT MagickImage::AddArgs(LPCSTR lpstr)
{
HRESULT hr = E_OUTOFMEMORY;
@@ -1384,15 +1361,15 @@
return hr;
hr = S_OK;
-#ifdef _UNICODE
- MAKE_ANSIPTR_FROMWIDE(ptrANSI, lpstr);
-#else
- MAKE_COPY_OF_ANSI(ptrANSI, lpstr);
-#endif
- m_argv[m_argvIndex++] = ptrANSI;
+
+ CA2W wsArg( lpstr );
+ CW2A sArgUTF8( wsArg, CP_UTF8 );
+ CW2A sArgANSI( wsArg );
+
+ m_argv[m_argvIndex++] = strdup( sArgUTF8 );
(void) MagickLib::LogMagickEvent(MagickLib::ResourceEvent,GetMagickModule(),
- "arg: %s",ptrANSI);
+ "arg: %s", (LPSTR)sArgANSI );
if (m_argvIndex >= m_argc)
hr = ReAllocateArgs( nDefaultArgumentSize );
@@ -1403,17 +1380,15 @@
HRESULT MagickImage::AllocateArgs(int cArgc)
{
m_argv = new LPTSTR [cArgc];
- m_argv_t = new LPTSTR [cArgc];
- if ((m_argv == NULL) || (m_argv_t == NULL))
+ if (m_argv == NULL)
return E_OUTOFMEMORY;
+
m_argc = cArgc;
-
m_argvIndex = 0;
for (int i=0; i<m_argc; i++)
{
m_argv[i] = NULL;
- m_argv_t[i] = NULL;
}
return S_OK;
}
@@ -1421,13 +1396,11 @@
HRESULT MagickImage::ReAllocateArgs(int cArgc)
{
LPTSTR *argv = m_argv;
- LPTSTR *argv_t = m_argv_t;
int argc = m_argc + cArgc;
argv = new LPTSTR [argc];
- argv_t = new LPTSTR [argc];
- if ((argv == NULL) || (argv_t == NULL))
+ if (argv == NULL)
return E_OUTOFMEMORY;
for (int i=0; i<argc; i++)
@@ -1435,12 +1408,10 @@
if (i < m_argc)
{
argv[i] = m_argv[i];
- argv_t[i] = m_argv_t[i];
}
else
{
argv[i] = NULL;
- argv_t[i] = NULL;
}
}
if (m_argv)
@@ -1448,11 +1419,6 @@
delete m_argv;
m_argv = argv;
}
- if (m_argv_t)
- {
- delete m_argv_t;
- m_argv_t = argv_t;
- }
m_argc = argc;
return S_OK;
}
@@ -1462,8 +1428,6 @@
EmptyArgs();
if (m_argv)
delete m_argv;
- if (m_argv_t)
- delete m_argv_t;
}
char **MagickImage::GetArgv()
@@ -1471,11 +1435,6 @@
return m_argv;
}
-char **MagickImage::GetArgvT()
-{
- return m_argv_t;
-}
-
int MagickImage::GetArgc()
{
return m_argvIndex;
@@ -1485,12 +1444,8 @@
{
for (int i=0; i<m_argc; i++)
{
- if (m_argv[i] != NULL)
- delete (void *) (m_argv[i]);
+ free( (void *) (m_argv[i]) );
m_argv[i] = NULL;
- if (m_argv_t[i] != NULL)
- delete (void *) (m_argv_t[i]);
- m_argv_t[i] = NULL;
}
m_argvIndex = 0;
}
@@ -1652,86 +1607,28 @@
m_spObjectContext.Release();
}
-int LocalGetFieldCount( string &s, const TCHAR* psz )
-{
- int len = _tcslen( psz );
- int pos = 0;
- int iCount = 1;
+typedef CAtlArray<CStringA> CStringArray;
- while( (pos = s.find(psz, pos)) >= 0 )
- {
- pos += len;
- iCount++;
- }
- return iCount;
-};
-
-int LocalGetFieldCount( string &s, const TCHAR& ch )
+static void LocalTokenize( const CString& s, LPCSTR sz, CStringArray& asToken )
{
- int pos = 0;
- int iCount = 1;
+ int nPos = 0;
+ CStringA sToken;
+
+ asToken.RemoveAll();
+ sToken = s.Tokenize( sz, nPos );
+ while( !sToken.IsEmpty() )
+ {
+ asToken.Add( sToken );
+ }
+
+ if ( asToken.GetCount() == 0 )
+ {
+ asToken.Add( s );
+ }
+}
- while( (pos = s.find(ch, pos)) >= 0 )
- {
- pos++;
- iCount++;
- }
- return iCount;
-};
-
-string LocalGetField( string &s, const TCHAR* delim, int fieldnum )
-{
- int lenDelim = _tcslen( delim );
- int pos = 0, term = 0;
- int retlen = 0, retpos = 0;
-
- while( fieldnum-- >= 0 )
- {
- term = s.find(delim, pos);
- if( term >= 0 )
- {
- retpos = pos;
- retlen = term - pos;
- pos = term + lenDelim;
- }
- else
- {
- retpos = pos;
- retlen = s.length() - pos;
- break;
- }
- }
- return s.substr(retpos, retlen);
-};
-
-string LocalGetField( string &s, const TCHAR& ch, int fieldnum )
-{
- int pos = 0, term = 0;
- int retlen = 0, retpos = 0;
-
- while( fieldnum-- >= 0 )
- {
- term = s.find(ch, pos);
- if( term >= 0 )
- {
- retpos = pos;
- retlen = term - pos;
- pos = term + 1;
- }
- else
- {
- retpos = pos;
- retlen = s.length() - pos;
- break;
- }
- }
- return s.substr(retpos, retlen);
-};
-
HRESULT MagickImage::Construct(IDispatch * pCtorObj)
{
- USES_CONVERSION;
-
(void) MagickLib::LogMagickEvent(MagickLib::ResourceEvent,GetMagickModule(),
"Construct");
CComPtr<IObjectConstructString> spObjectConstructString;
@@ -1742,34 +1639,46 @@
hr = spObjectConstructString->get_ConstructString(&bstrConstruct);
if (SUCCEEDED(hr))
{
- string options;
- MAKE_ANSIPTR_FROMWIDE(ptrANSI, bstrConstruct);
+ CStringA sOptions( bstrConstruct );
+ int nPos = 0;
+ CStringA sToken;
+ CStringArray asToken;
+
(void) MagickLib::LogMagickEvent(MagickLib::ResourceEvent,GetMagickModule(),
- "Construct data: %s",ptrANSI);
- options = W2CA(bstrConstruct);
- int nOptions = LocalGetFieldCount(options,_T(','));
- for (int nOptionIndex = 0; nOptionIndex < nOptions; nOptionIndex++)
+ "Construct data: %s", (LPCSTR)sOptions );
+
+ sToken = sOptions.Tokenize( ".", nPos );
+ while( !sToken.IsEmpty() )
{
- string param = LocalGetField( options, _T(','), nOptionIndex );
- int nParams = LocalGetFieldCount(param,_T('='));
- if (nParams == 2)
- {
- string name = LocalGetField( param, _T('='), 0 );
- string value = LocalGetField( param, _T('='), 1 );
+ LocalTokenize( sToken, "=", asToken );
+ if ( asToken.GetCount() == 2 )
+ {
+ const CStringA& sName = asToken[0];
+ const CStringA& sValue = asToken[1];
+
(void) MagickLib::LogMagickEvent(MagickLib::ResourceEvent,GetMagickModule(),
"Construct name: %s value: %s",
- name.c_str(),value.c_str());
+ (LPCSTR)sName,(LPCSTR)sValue);
+
#if defined(_ENABLE_OLD_LOGGING_SUPPORT_)
- if (name.compare(_T("MAGICK_DEBUG_LEVEL")) == 0)
- MagickLib::DebugLevel(atoi(value.c_str()));
- if (name.compare(_T("MAGICK_DEBUG_PATH")) == 0)
- MagickLib::DebugFilePath(value.c_str());
- if (name.compare(_T("MAGICK_LOG_EVENTMASK")) == 0)
- MagickLib::SetLogEventMask(value.c_str());
+ if (sName.Compare("MAGICK_DEBUG_LEVEL") == 0)
+ {
+ MagickLib::DebugLevel( atoi(sValue) );
+ }
+
+ if (sName.Compare("MAGICK_DEBUG_PATH") == 0)
+ {
+ MagickLib::DebugFilePath(sValue);
+ }
+
+ if (sName.Compare("MAGICK_LOG_EVENTMASK") == 0)
+ {
+ MagickLib::SetLogEventMask(sValue);
+ }
#endif
- }
- }
- }
- }
+ } // if
+ } // while
+ } // if
+ }
return hr;
}
Index: ImageMagickObject_.h
===================================================================
--- ImageMagickObject_.h (revision 14073)
+++ ImageMagickObject_.h (working copy)
@@ -1,98 +1,60 @@
-#pragma once
-#ifndef STRICT
-#define STRICT
-#endif
-#ifndef WINVER
-#define WINVER 0x0400
-#endif
-#ifndef _WIN32_WINNT
-#define _WIN32_WINNT 0x0400
-#endif
-#ifndef _WIN32_WINDOWS
-#define _WIN32_WINDOWS 0x0410
-#endif
-#ifndef _WIN32_IE
-#define _WIN32_IE 0x0400
-#endif
-#define _ATL_ATTRIBUTES
-#define _ATL_APARTMENT_THREADED
-#define _ATL_NO_AUTOMATIC_NAMESPACE
-#define _ATL_CSTRING_EXPLICIT_CONSTRUCTORS
-#define _ATL_ALL_WARNINGS
-#pragma warning(disable: 4103) // pragma pack
-#define _WINSOCKAPI_
-#include <atlbase.h>
-#include <atlcom.h>
-#include <atlwin.h>
-#include <atltypes.h>
-#include <atlctl.h>
-#include <atlhost.h>
-#include <atlsafe.h>
-using namespace ATL;
-
-#include <asptlb.h> // Active Server Pages Definitions
-#include <comsvcs.h>
-
-#include <iostream>
-using namespace std;
-
-
-namespace MagickLib
-{
-#define _VISUALC_
-//#define _MAGICKDLL_
-//#define _MAGICKLIB_
-#include <wand/MagickWand.h>
-#include <magick/semaphore.h>
-#include <magick/nt-base.h>
-#include <magick/log.h>
-#include <magick/hashmap.h>
-//#undef _MAGICKDLL_
-//#undef _MAGICKLIB_
-#undef inline
-#undef class
-}
-
-
-const DWORD dwErrorBase = 5000;
-const int nDefaultArgumentSize = 128;
-const LCID lcidDefault = 0;
-
-//
-// This routine converts a wide character string to ANSI and stores the new
-// string in a buffer allocated by the new operator
-//
-#define MAKE_WIDEPTR_FROMANSI(ptrname, ansistr) \
- long __l##ptrname = (lstrlen(ansistr) + 1) * sizeof(WCHAR); \
- void * __TempBuffer##ptrname = (void *) new char [ __l##ptrname ]; \
- MultiByteToWideChar(CP_ACP, 0, ansistr, -1, (LPWSTR)__TempBuffer##ptrname.GetBuffer(), __l##ptrname); \
- LPWSTR ptrname = (LPWSTR)__TempBuffer##ptrname
-
-//
-// This routine converts an ANSI string to a wide character string in a new
-// buffer area allocated using the new operator
-// We allocate lstrlenW(widestr) * 2 because its possible for a UNICODE char
-// to map to 2 ansi characters this is a quick guarantee that enough space
-// will be allocated.
-//
-#define MAKE_ANSIPTR_FROMWIDE(ptrname, widestr) \
- long __l##ptrname = (lstrlenW(widestr) + 1) * 2 * sizeof(char); \
- void * __TempBuffer##ptrname = (void *) new char [ __l##ptrname]; \
- WideCharToMultiByte(CP_ACP, 0, widestr, -1, (LPSTR)__TempBuffer##ptrname, __l##ptrname, NULL, NULL); \
- LPSTR ptrname = (LPSTR)__TempBuffer##ptrname
-
-#define MAKE_ANSIPTR_FROMWIDE_2(ptrname, widestr, wlen) \
- long __l##ptrname = (wlen + 1) * 2 * sizeof(char); \
- void * __TempBuffer##ptrname = (void *) new char [ __l##ptrname]; \
- WideCharToMultiByte(CP_ACP, 0, widestr, -1, (LPSTR)__TempBuffer##ptrname, __l##ptrname, NULL, NULL); \
- LPSTR ptrname = (LPSTR)__TempBuffer##ptrname
-//
-// This routine is used to make a copy of an existing ANSI string
-//
-#define MAKE_COPY_OF_ANSI(ptrname, ansistr) \
- long __l##ptrname = (lstrlen(ansistr) + 1); \
- void * __TempBuffer##ptrname = (void *) new char [ __l##ptrname ]; \
- lstrcpyn((LPSTR)__TempBuffer##ptrname, (LPCSTR)ansistr, __l##ptrname); \
- LPSTR ptrname = (LPSTR)__TempBuffer##ptrname
-
-#define _DbgBreak() __asm { int 3 }
+#pragma once
+#ifndef STRICT
+#define STRICT
+#endif
+#ifndef WINVER
+#define WINVER 0x0400
+#endif
+#ifndef _WIN32_WINNT
+#define _WIN32_WINNT 0x0400
+#endif
+#ifndef _WIN32_WINDOWS
+#define _WIN32_WINDOWS 0x0410
+#endif
+#ifndef _WIN32_IE
+#define _WIN32_IE 0x0400
+#endif
+#define _ATL_ATTRIBUTES
+#define _ATL_APARTMENT_THREADED
+#define _ATL_NO_AUTOMATIC_NAMESPACE
+#define _ATL_CSTRING_EXPLICIT_CONSTRUCTORS
+#define _ATL_ALL_WARNINGS
+#pragma warning(disable: 4103) // pragma pack
+#define _WINSOCKAPI_
+#include <atlbase.h>
+#include <atlcom.h>
+#include <atlwin.h>
+#include <atltypes.h>
+#include <atlctl.h>
+#include <atlhost.h>
+#include <atlsafe.h>
+#include <atlconv.h>
+#include <atlstr.h>
+#include <atlcoll.h>
+using namespace ATL;
+
+#include <asptlb.h> // Active Server Pages Definitions
+#include <comsvcs.h>
+
+namespace MagickLib
+{
+#define _VISUALC_
+//#define _MAGICKDLL_
+//#define _MAGICKLIB_
+#include <wand/MagickWand.h>
+#include <magick/semaphore.h>
+#include <magick/nt-base.h>
+#include <magick/log.h>
+#include <magick/hashmap.h>
+//#undef _MAGICKDLL_
+//#undef _MAGICKLIB_
+#undef inline
+#undef class
+}
+
+
+const DWORD dwErrorBase = 5000;
+const int nDefaultArgumentSize = 128;
+const LCID lcidDefault = 0;
+
+#define _DbgBreak() __asm { int 3 }