ホーム » Iwao の投稿 (ページ 51)

作者アーカイブ: Iwao

2025年5月
 123
45678910
11121314151617
18192021222324
25262728293031

カテゴリー

アーカイブ

ブログ統計情報

  • 114,185 アクセス


WM PowerToys

Windows Mobile Developer Power Toys


WM でコマンドプロンプトが利用できるとあったのでやってみたが... NG
この人と同じ様な現象.
console.dll が影響している?らしい.
エミュレータだとこんな感じ.
WM コマンド プロンプト


他に,Remote Display もやってみたが,うまくいかず.
MyMobiler ではうまくいった.


Remote Display でさらに調べてると,cerdisp2.exe を X02T に入れれば良さそうだったが,どれかわからず.
ここを参考に ActiveSync_remote_Display\devices\wce400\armv4t\* を X02T にコピーして,実行でうまくいった.
WM Remote Display

Is this 投稿 useful? Useful Useless 0 of 0 people say this 投稿 is useful.

C1083

—— ビルド開始 : プロジェクト : CalAxByC, 構成 : Debug Win32 ——
コンパイルしています…
StdAfx.cpp
c1xx : fatal error C1083: コンパイラの中間生成物 ファイルを開けません。’ .\Debug.070/CalAxByC.pch’: No such file or directory
CalAxByC – エラー 1、警告 0
———————- 終了 ———————-
ビルド : 0 正常終了、1 失敗、0 スキップ

出力ディレクトリなどの指定で .\$(ConfigurationName).070 の前にスペースが入っていた.


「UNICODE 文字セットを使用する」にすると,
—— ビルド開始 : プロジェクト : CalAxByC, 構成 : Debug Win32 ——
コンパイルしています…
CalAxByC.cpp
リンクしています…
LINK : warning LNK4075: /EDITANDCONTINUE は /INCREMENTAL:NO の指定によって無視されます。
msvcrtd.lib(wcrtexew.obj) : error LNK2019: 未解決の外部シンボル _wWinMain@16 が関数 _wWinMainCRTStartup で参照されました。
.\Debug.070/CalAxByC.exe : fatal error LNK1120: 外部参照 1 が未解決です。
CalAxByC – エラー 2、警告 1
———————- 終了 ———————-
ビルド : 0 正常終了、1 失敗、0 スキップ

この対応方法は vcproj を編集

Is this 投稿 useful? Useful Useless 0 of 0 people say this 投稿 is useful.

WM 5 版 ColorHSV クラステスト

zip 内の構成で,\\T54W7U64\Public\Documents\Temp\WM_Card にファイルを置いている.
WM_Card.2012.06.29.zip
デバイス エミュレータ マネージャ
VS 2005 の「ツール」-「デバイス エミュレータ マネージャ」を起動.
デバイスを選択して「接続」.
デバイスに接続
デバイス エミュレータの「ファイル」-「構成」で,「共有フォルダ」を指定.
デバイスの「ファイル エクスプローラ」で対象のフォルダに移動して起動.
ColorHSV を起動

Is this 投稿 useful? Useful Useless 0 of 0 people say this 投稿 is useful.

Windows Mobile 用修正

Windows Mobile プロジェクトで利用した場合のエラー.
但し,今は 2012.07 の関係があるため _CE フォルダを作成してそれを利用している.


C:\…\HelpAPI.hxx(28) : error C2660: ‘GetLongPathName’ : 関数に 3 個の引数を指定できません。
C:\…\HelpAPI.hxx(58) : error C2660: ‘GetComputerName’ : 関数に 2 個の引数を指定できません。
C:\…\HelpAPI.hxx(76) : error C2660: ‘GetUserName’ : 関数に 2 個の引数を指定できません。
C:\…\HelpAPI.hxx(106) : error C2660: ‘GetCurrentDirectory’ : 関数に 2 個の引数を指定できません。
C:\…\HelpAPI.hxx(121) : error C2660: ‘GetFullPathNameW’ : 関数に 4 個の引数を指定できません。
機能としてなさそう.関数を _WIN32_WCE で無効に.


c:\…\CRT_MBWC.hxx(113) : error C3861: ‘_tcsncat_s’: 識別子が見つかりませんでした
c:\…\CRT_MBWC.hxx(144) : error C3861: ‘_vstprintf_s’: 識別子が見つかりませんでした
c:\…\CRT_MBWC.hxx(168) : error C3861: ‘_vstprintf_s’: 識別子が見つかりませんでした
c:\…\CRT_MBWC.hxx(447) : error C3861: ‘_i64tot_s’: 識別子が見つかりませんでした
c:\…\CRT_MBWC.hxx(459) : error C3861: ‘_ui64tot_s’: 識別子が見つかりませんでした
c:\…\CRT_MBWC.hxx(488) : error C3861: ‘_tstof’: 識別子が見つかりませんでした
_s が付かないものや,他の関数に置き換え.


C:\…\WinMFC.hxx(297) : error C2065: ‘HDROP’ : 定義されていない識別子です。
C:\…\WinMFC.hxx(297) : error C2146: 構文エラー : ‘)’ が、識別子 ‘hDropInfo’ の前に必要です。
C:\…\WinMFC.hxx(297) : error C2433: ‘DropFilesToStringArray’ : ‘inline’ はデータ宣言をするのに使用できません。
C:\…\WinMFC.hxx(297) : error C2059: 構文エラー : ‘)’
C:\…\WinMFC.hxx(298) : error C2143: 構文エラー : ‘;’ が ‘{‘ の前にありません。
C:\…\WinMFC.hxx(298) : error C2447: ‘{‘ : 対応する関数ヘッダーがありません (旧形式の仮引数リスト?)
関数を無効に.


C:\…\WinMFC.hxx(477) : error C2589: ‘(‘ : スコープ解決演算子 (::) の右側にあるトークンは使えません。
C:\…\WinMFC.hxx(477) : error C2059: 構文エラー : ‘::’
C:\…\WinMFC.hxx(479) : error C2589: ‘(‘ : スコープ解決演算子 (::) の右側にあるトークンは使えません。
C:\…\WinMFC.hxx(479) : error C2143: 構文エラー : ‘;’ が ‘::’ の前にありません。
クリップボードへのテキスト転送の部分ではあるが,ちょっとわからず.関数を.無効に.


Is this 投稿 useful? Useful Useless 0 of 0 people say this 投稿 is useful.

VC 2005 MFC スマートデバイス AP

以下の様なコードが動作する様に幾つかを書換えてテスト.
  CString TF_GetRunStatus (void)
  {
    CStringArray sa ;
    {
      sa.Add(::GetTempPath ()) ;
      sa.Add(::GetModuleFileName ()) ;
      sa.Add(::IsWow64()?_T(“Wow64”):_T(“”)) ;
      }
    {
      double osVer = ::OS__GetVersion() ;
      sa.Add(::FtoT (osVer)) ;
      CString str ; str.Format(_T(“%f”),osVer) ;
      sa.Add(str) ;
      }
  #ifndef _WIN32_WCE
    sa.Add(::GetComputerName ()) ;
    sa.Add(::GetUserName ()) ;
    sa.Add(::GetCurrentDirectory()) ;
    sa.Add(::GetFullPathName (_T(“.\\”))) ;
  #endif
    sa.Add(::GetBuildStrFull ()) ;
    CString str ;
    ::StringArrayToString(sa,str) ;
    return str ;
    }
VC 2005 MFC スマートデバイス AP


::GetTempPath
  PPC2003  “\Temp\”
  SP 2003   “\Strage\Application Data\Volatile\”
  WM 5,6   ”\Application Data\Volatile\”

Is this 投稿 useful? Useful Useless 0 of 0 people say this 投稿 is useful.

LOG_PBH::Term

「LOG_PBH::Term が呼ばれる前に Init が呼ばれた」
以下の様なコードで,PBH::SetDefaultPenBrush() が呼ばれていないと,デバッグウィンドウに表示される.
  {
    LOGPEN lp ;
    LOGBRUSH lb ;
    PBH::GetHatchPenBrush(pDC,GetPBH(), &lp,&lb) ;
    CPen pen ; pen.CreatePenIndirect(&lp) ;
    CPen* oldPen = pDC->SelectObject(&pen) ;
    CBrush brush ; brush.CreateBrushIndirect(&lb) ;
    CBrush* oldBrush = pDC->SelectObject(&brush) ;
    Parts::Draw(pDC,prj,scale) ;
    pDC->SelectObject(oldPen) ;
    pDC->SelectObject(oldBrush) ;
    PBH::SetDefaultPenBrush() ;
    }

Is this 投稿 useful? Useful Useless 0 of 0 people say this 投稿 is useful.

PAtoMHD.AsPln2D を …

PAtoMHD.AsPln2D を IIS のコンポーネントとして登録.
DrawVer.asp
  <%@ Language=VBScript %>
  <% Option Explicit %>
  <HTML>
  <BODY>
  <%
  dim oToPA
  set oToPA = Server.CreateObject(“PAtoMHD.AsPln2D”)
  Response.Write oToPA.GetVersion
  set oToPA = Nothing
  %>
  </BODY>
  </HTML>


実行すると,
エラー タイプ
Server オブジェクト, ASP 0178 (0x80070005)
許可を確認中に Server.CreateObject の呼び出しに失敗しました。このオブジェクトへのアクセスは拒否されます。
/Test/DrawVer.asp, line 7

「コンポーネント サービス」-「DCOM の構成」で「セキュリティ」タブ内の設定.

IIS を再起動する


以下の様にしていると
  set oMICS = Server.CreateObject(“AsMicsS.Application”)
  set oToPA = Server.CreateObject(“PAtoMHD.AsPln2D”)
PAtoMHD.exe は IUSR_DEVXP となるが,AsMicsS.exe は SYSTEM でリフレッシュ毎に起動されてしまっている.

どうも,PAtoMHD.Application などの場合に複数起動されているみたい.
IUSR_~ と SYSTEM の違いはよくわからない.

Is this 投稿 useful? Useful Useless 0 of 0 people say this 投稿 is useful.

VC 6 MFC でオートメーション利用

「Class Wizard」-「クラスの追加」-「タイプライブラリから」
タイプライブラリからのクラスの追加
InitInstance 内の追加のコード
  #ifdef _AFXDLL
    Enable3dControls();
  #else
    Enable3dControlsStatic();
  #endif

  {  // 利用をこのブロックにまとめてます
    AfxOleInit() ;
    IAsPln2D to2D ;
    if (!to2D.CreateDispatch(_T(“PAtoMHD.AsPln2D”))) {
      return FALSE ;
      }
    CString selFile = to2D.BrowseFile(_T(“.\\*.mhd”),_T(“mhd を選択してください”)) ;
    if (!selFile.IsEmpty()) {
      if (to2D.Load(selFile)) {
        to2D.Save(selFile+_T(“.svg”)) ;
        }
      }
    return FALSE ;
    }
  CTestDlg dlg;
  …


#import を利用する方法
  アプリケーションクラスのソースに
    #import “C:\…\SVG\PAtoMHD\Release\PAtoMHD.tlb”
  InitInstance に
  {
    AfxOleInit() ;
    PAtoMHD::IAsPln2DPtr to2D ;
    if (to2D.CreateInstance(__uuidof(PAtoMHD::AsPln2D)) != S_OK) {
      return FALSE ;
      }
    CString selFile = LPCTSTR(to2D->BrowseFile(_T(“.\\*.mhd”),_T(“mhd を…”))) ;
    if (!selFile.IsEmpty()) {
      if (to2D->Load(LPCTSTR(selFile))) {
        to2D->Save(LPCTSTR(selFile+_T(“.svg”))) ;
        }
      }
    return FALSE ;
    }
CreateInstance の時の PAtoMHD::AsPln2D がわからなかった.
PAtoMHD::IAsPln2D としてしまっていた.


Dr. GUI、コンポーネント、COM、および ATL を使う

Is this 投稿 useful? Useful Useless 0 of 0 people say this 投稿 is useful.

ipx , PartsA , PartsA_C3D

2012/04/25 以前の PartsA などの ipx の読込みは,CArchive::ReadString を利用していた.
今回,Parts ファミリのファイルアクセスは,LoadText ,SaveText に置き換える.


ReadString を利用していた時の動作
  PartsA_C3D::ImportTxt より PartsA::SerializeTxt が呼ばれる.
   PACnv3.exe!PartsA::SerializeTxt(CArchive & ar={…}) 行 464
   PACnv3.exe!PartsA::Serialize(CArchive & ar={…}) 行 361
   PACnv3.exe!PartsA_C3D::ImportTxt(… * pathName) 行 336
   PACnv3.exe!PartsA_C3D::Import(… * pathName) 行 137
   PACnv3.exe!CPACnv3Doc::OnOpenDocument(… * lpszPathName) 行 177
  PartsA_C3D::ImportTxt で,exe と ipx の種類により,ReadString で読める形式でコピーする.
   FileMBWC.hxx GetReadTextName により,
    UNICODE.exe の場合,UTF-16 のテキストファイルにコピーする.
  PartsA::Serialize を呼出す前には,BOM を読み飛ばした位置にポインタがある.
   FileMBWC.hxx SerializeTextBOM(ar) により,UNICODE.exe の場合に飛ばす.
  * PartsA_C3D を利用してない exe では,形式が異なるファイルは読み出せなかった.
    VxxxxV などの exe は,PartsA::Serialize としているのでこれにあたる.


ReadString を利用しない様にしたので,PartsA_C3D::ImportTxt は,シンプルになった.
  BOOL PartsA_C3D::ImportTxt (LPCTSTR pathName)
  {
    if (!PartsA::IsTextFile(pathName)) { return FALSE ; }
    CString str ;
    if (!::LoadText(pathName,str))   { return FALSE ; }
    return PartsA::ImportTxt(str) ;
    }

Is this 投稿 useful? Useful Useless 0 of 0 people say this 投稿 is useful.

HTML の表示

SVG をダイアログ上に表示したくなったので,CHtmlView などを利用してみた.
Spy++ で見ると,クラス名が “Internet Explorer_Server” となる.
HtmlView.zip


SDI で CHtmlView を利用
1. AppWizard のステップ 6 で,CHtmlView を選択する.

2. ビューのソースの CXxxxView::OnInitialUpdate() を,適当なアドレスに修正する.
  Navigate2(_T(“https://mish.myds.me/wordpress/dev/“),NULL,NULL);


ダイアログで,WebBrowser Control を利用
1. プロジェクトにコンポーネントを追加する.

2. 追加したコントロールの変数を割り当てる(ここでは,m_WebBrowse とした).
3. OnInitDialog などで
 m_WebBrowse.Navigate(_T(“https://mish.myds.me/wordpress/dev/“),NULL,NULL,NULL,NULL) ;


ダイアログで,CHtmlView を利用
1. CHtmlView* の変数を定義する(ここでは,WebView とした).
2. OnInitDialog で
  CRect rect ;
  GetClientRect(&rect) ;
  rect.top = 25 ;
  CRuntimeClass* pClass= RUNTIME_CLASS(CHtmlView) ;
  WebView = (CHtmlView*)(pClass->CreateObject()) ;
  WebView->Create(NULL,NULL,WS_VISIBLE|WS_CHILD,rect,this,0,NULL) ;
  WebView->SendMessage(WM_INITIALUPDATE) ;
  WebView->Navigate(_T(“https://mish.myds.me/wordpress/dev/“)) ;

Is this 投稿 useful? Useful Useless 0 of 0 people say this 投稿 is useful.

コード分析による修正

VC 9

~\CharFnc.hxx(155) : warning C6284: オブジェクトがパラメータ '3' として渡されました。
~\CharFnc.hxx(155) : warning C6284: オブジェクトがパラメータ '5' として渡されました。
  str.Format(_T("(%*s,%*s)"),width,        ToString(value.x) ,width,        ToString(value.y) ) ;
  str.Format(_T("(%*s,%*s)"),width,LPCTSTR(ToString(value.x)),width,LPCTSTR(ToString(value.y))) ;
  間違って LPCSTR としてしまうと,_UNICODE では
    error C2440: '' : 'CString' から 'LPCSTR' に変換できません。
  LPSTR としてしまうと,
    error C2440: '' : 'CString' から 'LPSTR' に変換できません。
Is this 投稿 useful? Useful Useless 0 of 0 people say this 投稿 is useful.

BDoc ファミリ

コンパイルで以下の様なエラーになった場合
c:\…\DocIB.cxx(77) : error C2065: ‘BDocCSV_D’ : 定義されていない識別子です。
c:\…\DocIB.cxx(77) : error C2146: 構文エラー : ‘;’ が、識別子 ‘bdcsv’ の前に必要です。
c:\…\DocIB.cxx(77) : error C2065: ‘bdcsv’ : 定義されていない識別子です。
c:\…\DocIB.cxx(78) : error C2228: ‘.Read’ : 左側がクラス、構造体、共用体ではありません。
c:\…\DocIB.cxx(79) : error C2228: ‘.BDoc_Draw’ : 左側がクラス、構造体、共用体ではありません。
c:\…\DocIB.cxx(79) : error C2653: ‘BDoc_Draw’ : 識別子がクラス名でも名前空間名でもありません。

DocIB.cxx のインクルードする場所をもう少し前にすることによりエラーはなくなるが,…


実行時,いろいろな所でダウンする(表面化しないこともあり).
BDoc_Draw と BDocCSV_D の定義の不整合が原因.
BDoc ファミリや,AccessItemND を見直さなければならないがちょっと時間が取れない.


ひとまず,App.h に BDoc_D.hxx をインクルードすることにより対応する.
#include “MetaFile.hxx”
#include “MemoryDC.hxx”
#include “BDoc_D_.hxx”

Is this 投稿 useful? Useful Useless 0 of 0 people say this 投稿 is useful.

VC 7.1 メモリウィンドウ

VC71 Memory UNICODE

Is this 投稿 useful? Useful Useless 0 of 0 people say this 投稿 is useful.

Shell Extension 2012.03.22

Is this 投稿 useful? Useful Useless 0 of 0 people say this 投稿 is useful.

CFont::CreatePointFont でアサート

—————————
Microsoft Visual C++ Debug Library
—————————
Debug Assertion Failed!

Program: C:\WINDOWS\explorer.exe
File: wingdix.cpp
Line: 269

For information on how your program can cause an assertion
failure, see the Visual C++ documentation on asserts.

(Press Retry to debug the application)
—————————
中止(A) 再試行(R) 無視(I)
—————————
CreatePointFont CMetaFile
ここ 1 年位のコードで何個かあったので,…
呼び元で与えられた pDC が CMetaFileDC の場合,m_hAttribDC が NULL となるため.
コードを書いた段階では画面やプリンタだったが,今回 Text → EMF で表面化した.
修正は以下の様な感じ.

//	font.CreatePointFont(120,faceName,pDC) ;
if (pDC->m_hAttribDC == NULL)	{   font.CreatePointFont(120,faceName,NULL) ;  }
else				{   font.CreatePointFont(120,faceName,pDC) ;   }
Is this 投稿 useful? Useful Useless 0 of 0 people say this 投稿 is useful.

CCheckListBox の使い方

1. 通常の手順で,リストボックスをダイアログに貼り付ける.
2. コントロールのプロパティを「オーナー描画」-「固定」,「文字列あり」-「チェック」に変更する.
3. クラスウィザードなどを利用して,コントロールの変数(CListBox)を登録する.
4. ヘッダファイルを開いて,CListBox を CCheckListBox に変更する.
5. 項目の追加は,CListBox などと同様に AddString など.
6. チェックの指定は,SetCheck で.
CheckListBox のプロパティ
CCheckListBox の使い方


「MFC 14 以降で表示がずれる」の対応

Is this 投稿 useful? Useful Useless 1 of 1 people say this 投稿 is useful.

Shell Extension InfoTip の追加

Shell Extension の作成 InfoTip

1.プロジェクトの作成
 MFC App Wizard(dll)
  「スタティックライブラリを使用した DLL」を選択
  「オートメーション」のサポート
2.クラスファクトリの作成
 Class Wizard で,クラスの新規作成
  基本クラスは CCmdTarget
  「タイプ ID で作成」
3.ヘッダ部に INTERFACE_PART の追加
 BEGIN_INTERFACE_PART(QueryInfoT,IQueryInfo)
  STDMETHOD (GetInfoFlags) (DWORD* pdwFlags) ;
  STDMETHOD (GetInfoTip ) (DWORD dwFlags,LPWSTR* ppwszTip) ;
 END_INTERFACE_PART (QueryInfoT)
 …
 BEGIN_INTERFACE_PART(PersistFile,IPersistFile)
 …
4.必要な変数を追加
 InfoTip の場合,FileName など
5.ソースに INTERFACE_MAP の追加
 BEGIN_INTERFACE_MAP(CI_ShellExt,CCmdTarget)
  INTERFACE_PART (CI_ShellExt,IID_IQueryInfo,QueryInfoT)
  INTERFACE_PART (CI_ShellExt,IID_IPersistFile,PersistFile)
 END_INTERFACE_MAP ()
6.CI_ShellExt::XQueryInfoT::~ の実装
 幾つかはある程度決まったコードになる.
CI_ShellExt::XQueryInfoT::GetInfoTipは,ppwszTipに表示する文字列を返す.


METHOD_PROLOGUE pThisでCCmdTargetの派生クラスにアクセス可能になる.


レジストリへの登録
[HKEY_CURRENT_USER\Software\Classes\CLSID\{56D044C5-9F47-4CD3-B130-9E52BE7460F3}]
@=”I.ShellExt”

[HKEY_CURRENT_USER\Software\Classes\CLSID\{56D044C5-9F47-4CD3-B130-9E52BE7460F3}\InProcServer32]
@=”C:\\Documents and Settings\\All Users\\Documents\\VC_TEST\\IShlExt\\Release\\I_Shl_E.dll”
“ThreadingModel”=”Apartment”

[HKEY_CURRENT_USER\Software\Classes\CLSID\{56D044C5-9F47-4CD3-B130-9E52BE7460F3}\ProgID]
@=”I.ShellExt”

拡張子の登録例
[HKEY_CURRENT_USER\Software\Classes\.Test_ShellExt\ShellEx\{00021500-0000-0000-C000-000000000046}]
@=”{56D044C5-9F47-4CD3-B130-9E52BE7460F3}”


{56D044C5-9F47-4CD3-B130-9E52BE7460F3} の部分は,ソースの IMPLEMENT_OLECREATE の前の行のコメントより


今回使用したコードは,IShlExt.zip


参考にしたのは,
Debugging with the Shell

MSDN Magazine 2000/04 新しいinfotip,アイコンオーバーレイ,シェルエクステンション
Windows 2000 UI Innovations: Enhance Your User’s Experience with New Infotip and Icon Overlay Shell Extensions

MSDN Magazine 2000/07 ハイパーテキストテンプレートファイルのカスタマイズによるエクスプローラの表示の拡張

Windows 95 ユーザーインターフェイス プログラミング


ExtractImage を実装してエラーになった場合
I_ShlExt.obj:error LNK2001:外部シンボル “_IID_IExtractImage” は未解決です
#include <initguid.h> を I_ShlExt.cpp の StdAfx.h の次に追加.

Is this 投稿 useful? Useful Useless 0 of 0 people say this 投稿 is useful.

XML の読込テスト – 4

全ては表現できてないが,msxml.dll により読込んだデータの関連はこんな感じか?

IXMLDOMDocument            
             
             
 documentElement  ——– IXMLDOMElement        
             
             
     attributes  ——– IXMLDOMNamedNodeMap    
             
         length     
         item 0  ——– IXMLDOMAttribute
         :    
         item n-1     name 
             value 
             
             
             
     childNodes  ——– IXMLDOMNodeList    
             
         length     
         item 0  ——– IXMLDOMElement
          :     
          :     
         item n-1  ——– IXMLDOMNode
             
             text 
     nodeName         
             
             
     tagName         
             
             
Is this 投稿 useful? Useful Useless 0 of 0 people say this 投稿 is useful.

XML の読込テスト – 3

BOOL ReadElement(
		MSXML::IXMLDOMElementPtr pElement,
		long indent
		) {
	CString tab = _T("\t\t\t\t\t\t\t\t\t\t\t\t\t") ;
	CString lsp = tab.Left(indent) ;
	if (pElement == NULL) { return FALSE ; }
	MSXML::IXMLDOMNodeListPtr pNode = pElement->GetchildNodes() ;
	{
		CString node = LPCTSTR(pElement->GetnodeName()) ;
		CString tagN = LPCTSTR(pElement->GettagName()) ;
		CString text ;
	// 	if (pNode->Getlength() == 0) {
			text = LPCTSTR(pElement->Gettext()) ;
	// 		}
		MSXML::IXMLDOMNamedNodeMapPtr aMap = pElement->Getattributes() ;
		CString str ;
		if (aMap != NULL) {
			str = ::ToString(aMap->Getlength()) ;
			for (int aIndex=0 ; aIndex<aMap->Getlength() ; aIndex++) {
				MSXML::IXMLDOMAttributePtr attr = aMap->Getitem(aIndex) ;
				if (attr == NULL) { continue ; }
				str += CString(_T("\t")) + LPCTSTR(attr->Getname()) ;
				str += CString(_T(" ")) + ::ToStringTC(LPCWSTR(attr->Getvalue().bstrVal)) ;
				}
			}
		cout << LPCTSTR(lsp) << LPCTSTR(node) << _T("\t") << LPCTSTR(text)
			<< _T("\t") << LPCTSTR(str)
			<< endl ;
		for (int index=0 ; index<pNode->Getlength() ; index++) {
			MSXML::IXMLDOMElementPtr child = pNode->Getitem(index) ;
			ReadElement(child,indent+1) ;
			}
		}
	return TRUE ;
	}

attr->value が,VARIANT で,VT_BSTR
これを LPCTSTR とすることは出来ず,::ToStringTC をしている.
 ::ToStringTC は引数とコンパイルオプションにより char* ⇔ wchar* が可能
 今回の場合,内部では ::WideCharToMultiByte で変換している.


要素の内容の取得はこんな感じか?

//	text = LPCTSTR(pElement->Gettext()) ;
	if (pNode->Getlength() > 0) {
		MSXML::IXMLDOMNodePtr	pText = pNode->Getitem(0) ;
		if (pText != NULL) {
			text = LPCTSTR(pText->text) ;
			}
		}

https://mish.work/joomla/index.php/cpp/xml.html

Is this 投稿 useful? Useful Useless 0 of 0 people say this 投稿 is useful.

XML の読込テスト – 2

要素へのアクセスはこんな感じと思われるが,Gettext の使い方がよくわからない.


BOOL ReadElement(MSXML::IXMLDOMElementPtr pElement,long indent)
{
CString tab = _T(“\t\t\t\t\t\t\t\t\t\t\t\t\t”) ;
CString lsp = tab.Left(indent) ;
if (pElement == NULL) { return FALSE ; }
MSXML::IXMLDOMNodeListPtr pNode = pElement->GetchildNodes() ;
{
CString node = LPCTSTR(pElement->GetnodeName()) ;
CString tagN = LPCTSTR(pElement->GettagName()) ;
CString text ;
// if (pNode->Getlength() == 0) {
text = LPCTSTR(pElement->Gettext()) ;
// }
cout << LPCTSTR(lsp) << LPCTSTR(node) << _T(“\t”) << LPCTSTR(text) << endl ;
for (int index=0 ; index<pNode->Getlength() ; index++) {
MSXML::IXMLDOMElementPtr child = pNode->Getitem(index) ;
ReadElement(child,indent+1) ;
}
}
return TRUE ;
}

BOOL TestXML (void)
{

if (pDoc->load(LPCTSTR(loadFile)) == VARIANT_TRUE) {
{
MSXML::IXMLDOMElementPtr root = pDoc->documentElement ;
ReadElement(root,0) ;
}
}

}


msxml.tlh をプロジェクトに追加すると,クラスビューで表示できる.
msxml.tlh Class View

Is this 投稿 useful? Useful Useless 0 of 0 people say this 投稿 is useful.