本文整理汇总了C++中StrUni::Bstr方法的典型用法代码示例。如果您正苦于以下问题:C++ StrUni::Bstr方法的具体用法?C++ StrUni::Bstr怎么用?C++ StrUni::Bstr使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类StrUni
的用法示例。
在下文中一共展示了StrUni::Bstr方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: TestCompare
void TestCollatingEngine::TestCompare(StrUni stuVal1, StrUni stuVal2, int nExpected)
{
HRESULT hr;
int nActual1, nActual2;
SmartBstr sbstrKey1, sbstrKey2;
SmartBstr sbstrVal1 = (stuVal1 ? stuVal1.Bstr() : NULL);
SmartBstr sbstrVal2 = (stuVal2 ? stuVal2.Bstr() : NULL);
// First comparison method
hr = m_qcoleng->Compare(sbstrVal1, sbstrVal2, fcoDefault, &nActual1);
TestHrFail(hr, "String compare");
// Make sure we get the same result with the other method:
// by getting the keys themselves and comparing them.
hr = m_qcoleng->get_SortKey(sbstrVal1, fcoDefault, &sbstrKey1);
TestFailZero(sbstrKey1, "get_SortKey");
TestHrFail(hr, "getting SortKey on string 1");
hr = m_qcoleng->get_SortKey(sbstrVal2, fcoDefault, &sbstrKey2);
TestFailZero(sbstrKey2, "get_SortKey");
TestHrFail(hr, "getting SortKey on string 2");
nActual2 = wcscmp(sbstrKey1, sbstrKey2);
if (sgn(nActual1) != sgn(nActual2))
Failure("String comparison yielded inconsistent results");
if (sgn(nActual1) != sgn(nExpected))
{
FailureFormat(L"Comparison of %s to %s gave %d instead of %d.",
(sbstrVal1 ? sbstrVal1 : L"NULL"), (sbstrVal2 ? sbstrVal2 : L"NULL"),
nActual1, nExpected);
}
return;
}
示例2: InitNew
/*----------------------------------------------------------------------------------------------
Initialize the data from the given file, or create a new empty string.
----------------------------------------------------------------------------------------------*/
void WpDa::InitNew(StrAnsi staFileName)
{
if (staFileName == "")
{
InitNewEmpty();
return;
}
Vector<StrUni> vstu;
ReadTextFromFile(staFileName, vstu);
HVO * prghvoPara = NewObj HVO[vstu.Size()];
for (int istu = 0; istu < vstu.Size(); istu++)
prghvoPara[istu] = istu + 2;
CacheVecProp(1, kflidStText_Paragraphs, prghvoPara, vstu.Size());
ITsStrFactoryPtr qtsf;
qtsf.CreateInstance(CLSID_TsStrFactory);
int enc = 100; // replace by the right number when we figure out what it is
for (istu = 0; istu < vstu.Size(); istu++)
{
StrUni stuPara = vstu[istu];
ITsStringPtr qtss;
CheckHr(qtsf->MakeStringRgch(stuPara.Chars(), stuPara.Length(), enc, &qtss));
CacheStringProp(istu + 2, kflidStTxtPara_Contents, qtss);
}
ITsPropsBldrPtr qtpb;
qtpb.CreateInstance(CLSID_TsPropsBldr);
StrUni stuNormal = L"Normal";
CheckHr(qtpb->SetStrPropValue(kspNamedStyle,stuNormal.Bstr()));
delete[] prghvoPara;
}
示例3: passed
void ViewTest1::TestFontName()
{
// Trying to retrieve via get_ without a previous put_
// Something to consider is if there can be a default font name in which case this
// test would not apply
SmartBstr sbstrName1;
HRESULT hr = m_qxvoTest->get_FontName(&sbstrName1);
TestHrFail(hr, "Function get_FontName failed when passed(by reference) a SmartBstr");
if (sbstrName1 != NULL)
Failure("get_FontName without initialization via put_ should have returned error");
// Sending NULL pointers to functions
// REVIEW LukeU This test is assuming that a font name of zero length is invalid
hr = m_qxvoTest->put_FontName(NULL);
if (!FAILED(hr))
Failure("Call to function: put_FontName(NULL) should have returned error unless "
"0 character font name is allowed");
hr = m_qxvoTest->get_FontName(NULL);
if (!FAILED(hr))
Failure("Call to function: get_FontName(NULL) should have returned error on NULL "
"pointer");
// "put_ing" and "get_ing" and subsequent value comparison
StrUni stuFontName = L"Garliz";
hr = m_qxvoTest->put_FontName(stuFontName.Bstr());
TestHrFail(hr, "Function put_FontName failed when passed(by value) a bstr");
CheckHr(m_qxvoTest->get_FontName(&sbstrName1));
if (wcscmp(stuFontName.Chars(), sbstrName1.Chars()))
Failure("FontName returned wrong result");
}
示例4: LoadIntoEmpty
/*----------------------------------------------------------------------------------------------
Load the data from the given file into an empty window.
----------------------------------------------------------------------------------------------*/
void WpDa::LoadIntoEmpty(StrAnsi staFileName, WpChildWnd * pwcw)
{
Assert(staFileName != "");
int ctss;
CheckHr(get_VecSize(1, kflidStText_Paragraphs, &ctss));
Assert(ctss <= 1);
Vector<StrUni> vstu;
ReadTextFromFile(staFileName, vstu);
HVO * prghvoPara = NewObj HVO[vstu.Size()];
for (int istu = 0; istu < vstu.Size(); istu++)
prghvoPara[istu] = istu + 2;
CacheVecProp(1, kflidStText_Paragraphs, prghvoPara, vstu.Size());
ITsStrFactoryPtr qtsf;
qtsf.CreateInstance(CLSID_TsStrFactory);
int enc = 100; // replace by the right number when we figure out what it is
for (istu = 0; istu < vstu.Size(); istu++)
{
StrUni stuPara = vstu[istu];
ITsStringPtr qtss;
CheckHr(qtsf->MakeStringRgch(stuPara.Chars(), stuPara.Length(), enc, &qtss));
CacheStringProp(istu + 2, kflidStTxtPara_Contents, qtss);
}
ITsPropsBldrPtr qtpb;
qtpb.CreateInstance(CLSID_TsPropsBldr);
StrUni stuNormal = L"Normal";
CheckHr(qtpb->SetStrPropValue(kspNamedStyle, stuNormal.Bstr()));
delete[] prghvoPara;
pwcw->ChangeNumberOfStrings(vstu.Size());
}
示例5: ProcessFormatting
/*----------------------------------------------------------------------------------------------
Change all the occurrences of the old styles names to the new names, and delete any
obsolete names.
----------------------------------------------------------------------------------------------*/
bool FwDbMergeStyles::ProcessFormatting(ComVector<ITsTextProps> & vqttp,
StrUni stuDelete)
{
bool fAnyChanged = false;
for (int ittp = 0; ittp < vqttp.Size(); ittp++)
{
SmartBstr sbstr;
HRESULT hr;
CheckHr(hr = vqttp[ittp]->GetStrPropValue(ktptNamedStyle, &sbstr));
if (hr == S_OK && sbstr.Length() > 0)
{
ITsPropsBldrPtr qtpb = NULL;
StrUni stuOld(sbstr.Chars());
StrUni stuNew;
if (Delete(stuOld))
{
CheckHr(vqttp[ittp]->GetBldr(&qtpb));
if (stuDelete.Length() == 0)
{
// If the style name to delete is empty, we want to pass null
// so that the named style string property is removed.
CheckHr(qtpb->SetStrPropValue(ktptNamedStyle, NULL));
}
else
CheckHr(qtpb->SetStrPropValue(ktptNamedStyle, stuDelete.Bstr()));
}
else if (Rename(stuOld, stuNew))
{
CheckHr(vqttp[ittp]->GetBldr(&qtpb));
CheckHr(qtpb->SetStrPropValue(ktptNamedStyle, stuNew.Bstr()));
}
if (qtpb)
{
ITsTextPropsPtr qttpNew;
CheckHr(qtpb->GetTextProps(&qttpNew));
vqttp[ittp] = qttpNew;
fAnyChanged = true;
}
}
}
return fAnyChanged;
}
示例6: SharonC
/*----------------------------------------------------------------------------------------------
Initialize an empty document. It has a document object (always ID 1!) and one paragraph
containing (implicitly) an empty string. Style is set to Normal
Review SharonC(JohnT): what encoding should the empty string have??
----------------------------------------------------------------------------------------------*/
void WpDa::InitNewEmpty()
{
HVO hvoPara = 2;
CacheVecProp(1, kflidStText_Paragraphs, &hvoPara, 1);
ITsStrFactoryPtr qtsf;
qtsf.CreateInstance(CLSID_TsStrFactory);
ITsStringPtr qtss;
int enc = 100;
CheckHr(qtsf->MakeStringRgch(L"", 0, enc, &qtss));
CacheStringProp(hvoPara, kflidStTxtPara_Contents, qtss);
ITsPropsBldrPtr qtpb;
qtpb.CreateInstance(CLSID_TsPropsBldr);
StrUni stuNormal = L"Normal";
CheckHr(qtpb->SetStrPropValue(kspNamedStyle, stuNormal.Bstr()));
}
示例7: Run
/*----------------------------------------------------------------------------------------------
Perform some tests on the LgCollatingEngine class.
Return S_OK if all tests succeed, or an appropriate COM error code.
----------------------------------------------------------------------------------------------*/
HRESULT TestCollatingEngine::Run()
{
HRESULT hr;
// WarnHr(E_FAIL);
#ifdef OLD_SOURCE_TREE
// Make a collater for English. Initialize it the standard way with a moniker.
IClassInitMonikerPtr qcim;
hr = qcim.CreateInstance(CLSID_ClassInitMoniker);
WarnHr(hr);
int lid = MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US);
hr = qcim->InitNew(CLSID_LgSystemCollater, (const BYTE *)&lid, isizeof(lid));
WarnHr(hr);
IBindCtxPtr qbc;
hr = ::CreateBindCtx(NULL, &qbc);
WarnHr(hr);
hr = qcim->BindToObject(qbc, NULL, IID_ILgCollatingEngine, (void **) &m_qcoleng);
WarnHr(hr);
#endif // def OLD_SOURCE_TREE
// ## ILgFontManagerPtr qfm;
// ## qfm.CreateInstance(CLSID_LgFontManager);
try
{
m_qcoleng.CreateInstance(CLSID_LgSystemCollater);
}
catch (Throwable & thr)
{
return thr.Error();
}
catch (...)
{
return WarnHr(E_FAIL);
}
// Create sort keys for some strings and use them.
StrUni stuValBlank = L"";
StrUni stuValSpace = L" a";
StrUni stuValA = L"a";
StrUni stuValB = L"b";
StrUni stuValAUpper = L"A";
StrUni stuValAnd = L"and";
StrUni stuValAny = L"any";
StrUni stuValAndUpper = L"And";
StrUni stuValPunct = L";(* #([/";
// REVIEW LarsH
#define FIXED_BUG_173 1
#ifdef FIXED_BUG_173
{
IgnoreWarnings iw;
hr = m_qcoleng->Compare(stuValB.Bstr(), stuValA.Bstr(), fcoDefault, NULL);
if (SUCCEEDED(hr))
Failure("Compare() with NULL return ptr should have failed");
}
#endif
int nRes = -1;
// NULL sbstrs are valid, but the CollatingOption isn't.
// REVIEW LarsH:
// Are invalid CollatingOptions are supposed to be ignored, or answered with an error?
{
IgnoreWarnings iw;
hr = m_qcoleng->Compare(NULL, stuValA.Bstr(), (enum LgCollatingOptions)37, &nRes);
if (!FAILED(hr))
Failure("get_SortKey with invalid option should have failed.");
// WarnHr(hr);
// if (nRes != -1)
// Failure("Compare() with invalid CollatingOption gave wrong answer");
}
// Try a sequence of test comparisions.
TestCompare(stuValBlank, stuValBlank, 0);
TestCompare(stuValBlank, stuValSpace, -1);
TestCompare(stuValBlank, stuValA, -1);
TestCompare(stuValBlank, stuValAUpper, -1);
TestCompare(stuValSpace, stuValA, -1);
TestCompare(stuValA, stuValBlank, 1);
TestCompare(stuValA, stuValB, -1);
TestCompare(stuValB, stuValA, 1);
TestCompare(stuValA, stuValAUpper, -1);
TestCompare(stuValB, stuValAUpper, 1);
TestCompare(stuValA, stuValAnd, -1);
TestCompare(stuValAny, stuValAnd, 1);
TestCompare(stuValAny, stuValAndUpper, 1);
TestCompare(stuValAnd, stuValAnd, 0);
TestCompare(stuValBlank, stuValPunct, -1);
TestCompare(stuValPunct, stuValA, -1);
TestCompare(stuValBlank, (wchar *)NULL, 0);
TestCompare((wchar *)NULL, stuValA, -1);
TestCompare(stuValA, (wchar *)NULL, 1);
//.........这里部分代码省略.........
示例8: Process
/*----------------------------------------------------------------------------------------------
Crawl through the database and rename/delete the given styles.
----------------------------------------------------------------------------------------------*/
STDMETHODIMP FwDbMergeStyles::Process(DWORD hWnd)
{
BEGIN_COM_METHOD;
Assert(m_vstuOldNames.Size() == m_vstuNewNames.Size());
if (!m_hvoRoot)
return E_UNEXPECTED;
if (!m_pclsidApp)
return E_UNEXPECTED;
if (LogFile())
{
ULONG cbLog;
StrAnsi staLog;
staLog.Format("Changing style names in %S (%S)%n",
DbName().Chars(), ServerName().Chars());
LogFile()->Write(staLog.Chars(), staLog.Length(), &cbLog);
}
m_qprog->DoModeless((HWND)hWnd);
StrUni stuMsg(kstidChgStyleLabel);
m_qprog->put_Title(stuMsg.Bstr());
ResetConnection();
BeginTrans();
CreateCommand();
SetPercentComplete(0);
// We want to affect only a subset of the formatting and style information in the database,
// based on which program is currently running, since different programs may be using
// different sets of styles. This information is derived from m_hvoRoot and m_pclsidApp.
// (Unfortunately, there's no way to derive one of these values from the other one.) The
// current scheme works for Data Notebook, List Editor, TE, and LexText. Additional
// programs may introduce even more complexities.
// 1. Find all the owners of StStyle objects. This should match up to LangProject (Data
// Notebook and List Editor), Scripture (TE), or LexDb (LexText).
// 2. If an owner equals m_hvoRoot, then only those objects owned by m_hvoRoot have the
// string and paragraph formatting fixed. Except that LexText also wants to fix all the
// Text objects owned by the LangProject in addition to all the objects owned by the
// LexDb, so those have to be added to the collection of objects.
// 3. If none of the owners equals m_hvoRoot, we must be dealing with Data Notebook or List
// Editor, which share a common set of styles owned by the LangProject itself. In
// this case, we want all the objects owned by the LangProject except those owned by
// another owner of styles (or the LangProject Text objects, since those use the
// LexText styles even though they're not owned by the root object). (This isn't quite
// right if either TE or LexText does not actually own any styles yet, but we won't worry
// about this nicety.)
// 4. After creating a temp table containing just the ids of those objects of interest, we
// can then process all the relevant string formatting (via a string crawler) and
// paragraph StyleRules (later in this method)
// 5. Finally, we may need to fix the Style fields of the relevant UserViewField objects.
// These are limited by the psclsidApp argument, since the UserView objects are specific
// to specific applications. If pssclidApp indicates either Data Notebook or List
// Editor, then UserViewField objects belonging to both of those programs are fixed.
// Otherwise, only those UserViewField objects belonging to the specific program
// identified by psclsidApp are fixed.
ComBool fMoreRows;
UINT cbSpaceTaken;
ComBool fIsNull;
int hobj = 0;
int clid = 0;
bool fFixOwned = false;
int clidOwned = 0;
int hvoLangProj = 0;
Vector<int> vhvoOwners;
Vector<int> vclidOwners;
Vector<int> vhvoTexts;
StrUni stuCmd;
stuCmd.Format(L"SELECT DISTINCT c.Owner$, co.Class$ "
L"FROM CmObject c "
L"JOIN CmObject co on co.Id = c.Owner$ "
L"WHERE c.Class$ = %d",
kclidStStyle);
CheckHr(GetOleDbCommand()->ExecCommand(stuCmd.Bstr(), knSqlStmtSelectWithOneRowset));
CheckHr(GetOleDbCommand()->GetRowset(0));
CheckHr(GetOleDbCommand()->NextRow(&fMoreRows));
while (fMoreRows)
{
CheckHr(GetOleDbCommand()->GetColValue(1, reinterpret_cast <BYTE *>(&hobj),
isizeof(hobj), &cbSpaceTaken, &fIsNull, 0));
CheckHr(GetOleDbCommand()->GetColValue(2, reinterpret_cast <BYTE *>(&clid),
isizeof(clid), &cbSpaceTaken, &fIsNull, 0));
if (hobj == m_hvoRoot)
{
fFixOwned = true;
clidOwned = clid;
}
else if (clid == kclidLangProject)
{
hvoLangProj = hobj;
}
else
{
vhvoOwners.Push(hobj);
vclidOwners.Push(clid);
//.........这里部分代码省略.........
示例9: rcSrc
HRESULT ViewTest2::Run()
{
// Make a special VwGraphics (#define BASELINE in compiling it turns on special features).
// This VwGraphics will not draw (2nd arg false) but will record attempts at drawing into
// the baseline.
m_psts = NewObj SilTestSite();
m_qst.Attach(m_psts);
m_qvg.Attach(NewObj VwGraphics(m_psts, false, true));
m_qst->SetBaselineFile(SmartBstr(L"c:\\fw\\testlog\\log\\VwGraphics").Bstr());
// Todo LukeU(JohnT): make an off-screen bitmap HDC and initialize the VwGraphics to use it.
// Here is your off-screen bitmap and memory surface
HDC hdcScr, hdcMem;
hdcScr = GetDC(NULL);
hdcMem = CreateCompatibleDC(hdcScr);
HBITMAP hBitmap = CreateCompatibleBitmap(hdcMem, 400, 400);
SelectObject(hdcMem, hBitmap);
ReleaseDC(NULL, hdcScr);
m_qvg->Initialize(hdcMem);
// Make a dummy root site for the Root box to talk back to
m_qtrs.Attach(NewObj VwTestRootSite);
m_qtrs->SetVgObject(m_qvg);
Rect rcSrc(0, 0, 96, 96);
Rect rcDst(0, 0, 96, 96);
m_qtrs->SetSrcRoot(rcSrc);
m_qtrs->SetDstRoot(rcDst);
// Make our view constructor.
m_qtvc.Attach(NewObj TestStVc);
// Put some dummy data into a cache. HVO 1 identifies the text as a whole.
// Arbitrarily objects 2, 3, and 4 are the three paragraphs of our test data.
m_qda.Attach(NewObj VwCacheDa);
HVO rghvoPara[3] = {2, 3, 4};
m_qda->CacheVecProp(1, kflidStText_Paragraphs, rghvoPara, 3);
ITsStrFactoryPtr qtsf;
qtsf.CreateInstance(CLSID_TsStrFactory);
ITsStringPtr qtss;
int enc = 100;
StrUni stuPara0 = L"This is the first paragraph";
StrUni stuPara1 = L"Here is another paragraph, quite silly and trivial but it should "
L"help test things";
StrUni stuPara2 = L"I try to keep the text in these quite different so they can't be "
L"confused";
CheckHr(qtsf->MakeStringRgch(stuPara0.Chars(), stuPara0.Length(), enc, &qtss));
m_qda->CacheStringProp(rghvoPara[0], kflidStTxtPara_Contents, qtss);
CheckHr(qtsf->MakeStringRgch(stuPara1.Chars(), stuPara1.Length(), enc, &qtss));
m_qda->CacheStringProp(rghvoPara[1], kflidStTxtPara_Contents, qtss);
CheckHr(qtsf->MakeStringRgch(stuPara2.Chars(), stuPara2.Length(), enc, &qtss));
m_qda->CacheStringProp(rghvoPara[2], kflidStTxtPara_Contents, qtss);
ITsPropsBldrPtr qtpb;
qtpb.CreateInstance(CLSID_TsPropsBldr);
StrUni stuNormal = L"Normal";
CheckHr(qtpb->SetStrPropValue(kspNamedStyle, stuNormal.Bstr()));
// Make the root box and initialize it.
m_qrootb.CreateInstance(CLSID_VwRootBox);
// OK, we have a root box set up. Now we can try some tests on it!
TestInit();
TestDataAccess();
TestLayout(350);
TestDrawRoot();
TestOverlay();
TestMakeSimpleSel();
TestMakeTextSelection();
TestKeys();
TestMouse();
Testget_Site();
TestLoseFocus();
TestListener();
m_qrootb->Close();
m_qrootb.Clear();
m_qda.Clear();
DeleteDC(hdcMem);
DeleteObject(hBitmap);
return S_OK;
}
示例10: main
int main()
{
ComBool fIsNull = TRUE;
ComBool fMoreRows;
HRESULT hr;
long lTemp;
ULONG luId;
ULONG luSpaceTaken;
int nId;
wchar_t * pwszTemp = NULL;
IOleDbEncapPtr qode;
IOleDbCommandPtr qodc;
IOleDbCommandPtr qodc2;
StrUni suDatabase = L"TestLangProj";
StrUni suEthnologueCode = L"ABC";
StrUni suEthnologueCode2 = L"XYZ";
StrUni suServer = L""; // (local)
StrUni suParamName = L"@id";
StrUni suSqlDelete = L"delete cmobject where Id=9999998";
StrUni suSqlDelete2 = L"delete MultiBigStr$ where obj=9999998";
StrUni suSqlInsert = L"insert into cmobject (Guid$, Class$, Owner$, OwnFlid$) " \
L"values(newid(), 1, NULL, NULL)";
StrUni suSqlInsert2 = L"insert into MultiBigStr$ (Flid, Obj, Enc, Txt, Fmt) values("\
L"5016005, 9999998, 740664001, '-', 0x00)";
StrUni suSqlSelect0 = L"select contents a, contents b from StTxtPara where id=1351";
StrUni suSqlSelect1 = L"select ethnologuecode from LangProject";
StrUni suSqlSelect2 = L"select cast('zzz' as nvarchar) from LangProject";
StrUni suSqlSelect3 = L"select obj, 'Hello' + cast(obj as nvarchar) GREETING, txt " \
L"from MultiBigStr$ where obj=17060 or obj=1707";
StrUni suSqlSelect4 = L"select ethnologuecode from LangProject where id = ?";
StrUni suSqlSelect5 = L"select getDate()";
StrUni suSqlSelect6 = L"select itm.id, itm3.Dst, itm.Confidence, itm5.Txt, itm.DateCreated, "
L"itm.DateModified from CmPossibility_ as itm "
L"left outer join CmPossibility_Discussion as itm3 on itm3.Src = itm.id "
L"left outer join CmPossibility_Name as itm5 on itm5.obj = itm.Confidence "
L"and itm5.enc = 740664001 "
L"where itm.id in (315); "
L"select itm.obj, itm.txt, itm.flid, itm.enc, itm.fmt "
L"from CmPossibility_Name itm "
L"where itm.obj in (315) and itm.enc in (740664001,931905001) "
L"union all "
L"select itm.obj, itm.txt, itm.flid, itm.enc, itm.fmt "
L"from CmPossibility_Abbreviation itm where itm.obj in (315) and itm.enc in "
L"(740664001,931905001) "
L"union all "
L"select itm.obj, itm.txt, itm.flid, itm.enc, itm.fmt "
L"from CmPossibility_Description itm "
L"where itm.obj in (315) and itm.enc in (740664001,931905001)";
StrUni suSqlStoredProcMultiRowset = L"exec TestMultiRowsets$ ?, ? output";
StrUni suSqlStoredProcWithOutputParam = L"exec newobjid$ ? output";
StrUni suSqlStoredProcWithOutputParam2 = L"exec TestIOParam$ ?, ? output, ? output";
StrUni suSqlUpdate = L"update LangProject set EthnologueCode='ZZZ' where Id<>1";
StrUni suSqlUpdateWithParam = L"update LangProject set EthnologueCode=? where Id=?";
StrUni suSqlUpdateWithParam2 = L"update MultiBigStr$ set txt=? where obj=?";
char * szBigBlob;
char szParamOut[20] = "QQQ";
char szTemp[1024] = "LMN";
WCHAR wszParamInOut[20] = L"Hello";
WCHAR wszTemp[1024];
IUnknown * pIOleDbCommand = NULL;
// Initialize OLE
hr = CoInitialize(NULL);
if (FAILED(hr)) return EXIT_FAILURE;
// Create Instance of OleDbEncap object and open DataSource/Session.
qode.CreateInstance(CLSID_OleDbEncap);
qode->Init(suServer.Bstr(), suDatabase.Bstr());
/*------------------------------------------------------------------------------------------
EXAMPLE 1:
Simple SQL select statement retrieving a single column (a wide character string).
select ethnologuecode from LangProject
------------------------------------------------------------------------------------------*/
printf("\n===============================\nEXAMPLE 1\n===============================\n");
qode->CreateCommand(&qodc);
qodc->ExecCommand(suSqlSelect1.Bstr(), knSqlStmtSelectWithOneRowset);
qodc->GetRowset(1);
qodc->NextRow(&fMoreRows);
pwszTemp = reinterpret_cast<WCHAR *> (CoTaskMemAlloc(sizeof(WCHAR) * 20));
while (fMoreRows)
{
luSpaceTaken = 0;
qodc->GetColValue(1, reinterpret_cast <ULONG *>(pwszTemp), sizeof(WCHAR) * 20,
&luSpaceTaken, &fIsNull, 2);
if (luSpaceTaken)
{
// Not a NULL string.
wprintf(L"Value: %s\n", pwszTemp);
}
else
{
// NULL string
wprintf(L"Id: <null>\n");
}
qodc->NextRow(&fMoreRows);
}
//.........这里部分代码省略.........