誰知道在PB中怎樣調用Big2GB.ocx做字符集轉換的動作?
pbl能運行,運行PBD時總是報錯“0x026a10b”指令參考“0xb06b2de7”記憶體,記憶體不能為“written”
究竟是什麼原因造成此錯誤的?
------解决方案--------------------
Big2GB.ocx,做字符转换直接调用这个API函数即可
FUNCTION ulong LCMapString(ulong Locale,ulong dwMapFlags,ref string lpSrcStr,ulong cchSrc,ref string lpDestStr,ulong cchDest) LIBRARY "kernel32.dll" ALIAS FOR "LCMapStringA;ansi"
------解决方案--------------------
//Public function f_bigtogb (string as_text) returns string
//string as_text
oleobject pbobject
oleobject pbnvobject
string ls_text
long ll_status
double ld_result
pbobject = CREATE oleobject
ll_status = pbobject.connecttonewobject("BigToGB.Big2GB")
IF ll_status <> 0 THEN //2
run("Regsvr32 -i ~"Big2GB.ocx~"")
END IF //2
ls_text = pbobject.bigtogb(as_text)
pbobject.disconnectobject()
DESTROY pbobject
RETURN ls_text
------解决方案--------------------
//Public function f_gbtobig (string as_text) returns string
//string as_text
oleobject pbobject
oleobject pbnvobject
string ls_text
long ll_status
double ld_result
pbobject = CREATE oleobject
ll_status = pbobject.connecttonewobject("BigToGB.Big2GB")
IF ll_status <> 0 THEN //2
run("Regsvr32 -s ~"Big2GB.ocx~"")
ll_status = pbobject.connecttonewobject("BigToGB.Big2GB")
END IF //2
ls_text = pbobject.gbtobig(as_text)
pbobject.disconnectobject()
DESTROY pbobject
RETURN ls_text
------解决方案--------------------
bool to_chinese_unicodet(wchar_t* sbuff)
{
if (sbuff ==NULL
------解决方案--------------------
wcslen(sbuff) == 0) return false;
LCID lcid = MAKELCID(MAKELANGID(LANG_CHINESE,SUBLANG_CHINESE_TRADITIONAL),SORT_CHINESE_BIG5);
int nLength = LCMapStringW(lcid,LCMAP_TRADITIONAL_CHINESE,sbuff,-1,NULL,0);
if (nLength <= 0) return false;
wchar_t* tbuff=new wchar_t[nLength + 1];
LCMapStringW(lcid,LCMAP_TRADITIONAL_CHINESE,sbuff,-1,tbuff,nLength);
tbuff[nLength]=0;
wcscpy(sbuff,tbuff);
delete[] tbuff;
return true;
}
bool to_chinese_unicodes(wchar_t* tbuff)
{
if (tbuff ==NULL
------解决方案--------------------
wcslen(tbuff) == 0) return false;
LCID lcid = MAKELCID(MAKELANGID(LANG_CHINESE,SUBLANG_CHINESE_TRADITIONAL),SORT_CHINESE_BIG5);
int nLength = LCMapStringW(lcid,LCMAP_SIMPLIFIED_CHINESE,tbuff,-1,NULL,0);
wchar_t* sbuff=new wchar_t[nLength + 1];
LCMapStringW(lcid,LCMAP_SIMPLIFIED_CHINESE,tbuff,-1,sbuff,nLength);
tbuff[nLength]=0;
wcscpy(tbuff,sbuff);
delete[] sbuff;
return true;
}