Home |
Search |
Today's Posts |
#4
![]()
Posted to microsoft.public.excel.programming,microsoft.public.excel.sdk
|
|||
|
|||
![]()
The working C++ code sample I'm copying from passes strings as VT_BSTR,
and it uses the SysAllocString method of CString to convert the C strings into BSTR's for passing. Unfortunately, I can't seem to find a C equivalent of CString::SysAllocString(). BSTR b; b = SysAllocString(lpsz); parm1.vt = VT_BSTR; parm1.bstrVal = b; Got it to work. Turns out SysAllocString does work from C. It's just that it needs a multi-byte char string as input (I guess the C++ version has a variant that take and converts a regular char string. So in C, the conversion has to happen in 2 phases. This code works: BSTR b; LPCWSTR ws; int len; len = strlen(szStr) + 1; ws = (LPCWSTR) malloc(len*2); MultiByteToWideChar(CP_ACP, 0, szStr, len, ws, len*2); b = SysAllocString(ws); parm1.vt = VT_BSTR; parm1.bstrVal = b; free(ws); |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Passing Query String into MS Excel | Excel Programming | |||
Passing Query String into MS Excel | Excel Discussion (Misc queries) | |||
Passing a String in Array to Range as String | Excel Programming | |||
string passing to DLL | Excel Programming | |||
PASSING A STRING VALUE | Excel Programming |