M
Markus Strauss
First i need to tell you i am no C-Programer - i can only make some litle C
changes to the code to meet our needs.
Now i have the folowing problem. Our programm reads a SQL-String from the
resources and gives this to the oledbCommand. This is the macro which worked
fine with C++6.0:
#define DEF_RESCOMMAND(x, nResource) typedef x _CommandClass; \
static HRESULT GetDefaultCommand(LPCWSTR* ppszCommand) \
{ static char sCommand[1024]; \
static bool bInit=false; \
if (!bInit) {::LoadString(_Module.m_hInst,nResource,sCommand,1024);
bInit=true;} \
*ppszCommand = sCommand; \
return S_OK; \
}
When i compile this with C++7.0 i get the following error - pleace be
patient but i cant tell you the english errormessage only the german:
c:\Entwicklung V2.0\visKernel\qryTradeGroups.H(25): error C2440: '=' : 'char
[1024]' kann nicht in 'LPCWSTR' konvertiert werden
but means that CHAR could not be converted to LPCWSTR.
Now I changed this to the following form:
#define DEF_RESCOMMAND(x, nResource) typedef x _CommandClass; \
static HRESULT GetDefaultCommand(LPCWSTR* ppszCommand) \
{ static char sCommand[1024]; \
static bool bInit=false; \
if (!bInit) {::LoadString(_Module.m_hInst,nResource,sCommand,1024);
bInit=true;} \
*ppszCommand = CA2W(sCommand); \
return S_OK; \
}
I used a conversionfunction. Now it compiles ok, but at runtime the lifetime
of the converted string is to short, when the code leafes the code of the
macro, the string only contains 999999.... inside its okay. please tell me
what function to convert i need to use instead of CA2W or what else i should
change in the macro.
thx for your effort
Markus
changes to the code to meet our needs.
Now i have the folowing problem. Our programm reads a SQL-String from the
resources and gives this to the oledbCommand. This is the macro which worked
fine with C++6.0:
#define DEF_RESCOMMAND(x, nResource) typedef x _CommandClass; \
static HRESULT GetDefaultCommand(LPCWSTR* ppszCommand) \
{ static char sCommand[1024]; \
static bool bInit=false; \
if (!bInit) {::LoadString(_Module.m_hInst,nResource,sCommand,1024);
bInit=true;} \
*ppszCommand = sCommand; \
return S_OK; \
}
When i compile this with C++7.0 i get the following error - pleace be
patient but i cant tell you the english errormessage only the german:
c:\Entwicklung V2.0\visKernel\qryTradeGroups.H(25): error C2440: '=' : 'char
[1024]' kann nicht in 'LPCWSTR' konvertiert werden
but means that CHAR could not be converted to LPCWSTR.
Now I changed this to the following form:
#define DEF_RESCOMMAND(x, nResource) typedef x _CommandClass; \
static HRESULT GetDefaultCommand(LPCWSTR* ppszCommand) \
{ static char sCommand[1024]; \
static bool bInit=false; \
if (!bInit) {::LoadString(_Module.m_hInst,nResource,sCommand,1024);
bInit=true;} \
*ppszCommand = CA2W(sCommand); \
return S_OK; \
}
I used a conversionfunction. Now it compiles ok, but at runtime the lifetime
of the converted string is to short, when the code leafes the code of the
macro, the string only contains 999999.... inside its okay. please tell me
what function to convert i need to use instead of CA2W or what else i should
change in the macro.
thx for your effort
Markus