2024年5月
 1234
567891011
12131415161718
19202122232425
262728293031  

カテゴリー

アーカイブ

ブログ統計情報

  • 81,020 アクセス



CCmdUI::SetText

以前,VC 11 以降で メニューのテキストがうまく更新できない 現象があった.
この時,オーナードローを使っている所は解決した(個人的なコードのバグだった).
が,普通のサブメニューの方はうまくないままとなっていて,それを今回改めて調べてみた.


デバッガで追いかけると,CcmdUI::SetText は呼ばれている.
MFC のコードを見ると,ModifyMenu と SetMenuItemInfo の違いがある.
MFC 10 と 11 の CCmdUI::SetText


サブメニューの場合にうまくないのかと思い,単体テスト用のコードを書いてみたが,再現できない.

void CM_textView::OnUpdateMenuItem(CCmdUI* pCmdUI) 
{
	// TODO: Add your command update UI handler code here
	CString	now = CTime::GetCurrentTime().Format(_T("%H:%M:%S")) ;
	pCmdUI->SetText(now) ;
	}

void CM_textView::OnMenuItem(UINT nID) 
{
	// TODO: Add your command handler code here
	}

何か他の条件があるみたい.


CMenu::TrackPopupMenu で表示するメニューではうまく更新されている.
メニューバーの項目としてコマンドを割り当て,そこから TrackPopupMenu を呼出すことで対応.

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

DSM 7 と WordPress , Joomla!

2021/07 に Synology NAS の DSM を更新
WordPress は動作しているが Joomla! はうまくないまま.


今日 Maria DB と WordPress ,Joomla! の更新版があったので更新した.
DSM 7  WordPress
前回と同様 でうまく開かない.
WordPress のインストールされたところをみると .htaccess が存在しない.
以前バックアップしたものをコピー.
これで WordPress はうまく動作する様になった.
Joomla! の方は相変わらず.


2022/02
Joomla! は …/joomla/index.php/… の形式であれば問題ない.
そのため,直接参照している所に index.php/ を付加することで対応した.

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

VC リリースビルドのデバッグ

先日の VC 6 でのリリースビルドでうまくなかった現象
これをデバッグするための設定.
以前から何度か使っているが,今回コンパイル時の設定部分が何故かすぐにわからなかったのでメモ.
リリースビルドのデバッグ コンパイル設定
同様に,リンクの設定でも「Generate debug info」のチェックが必要.
方法: リリース ビルドをデバッグする

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

VS 6 RTM bug … ?

Win10 環境に入れた VC 6 でビルドした exe をテストしていると…
VC 6 RTM
「何か修正を間違えた?」と思い,幾つかの exe で実行するとうまくいく.
VC 6 SP6
VC 14 などでビルドしたものや,VC 6 デバッグビルドのものは OK .
2021/06 頃からの VC 6 リリースビルドのものがうまくなさそう.
WinXP 環境の VC 6 でビルドしたものも OK .
Win10 に入れた VS 6 が英語版だったので,SP はまだ入れていない.


2021/08/17
VC 6 RTM で作成される exe がうまくないものと思われる.
3D データ変換の状況


2021/08/18
次の様なコードでテストすると ::GonsA_Triangulation で長方形の片方が消えてしまう.

	GonsA	gnsa = ::To_GonsA(_3d_file) ;
	     	gnsa = ::GonsA_Triangulation(gnsa) ;
	::GonsA_Toix3(gnsa,(out_name+_T(".ix3")).c_str()) ;
	::GonsA_ToOBJ(gnsa,(out_name+_T(".imo")).c_str()) ;
	::GonsA_ToWRL(gnsa,(out_name+_T(".wrl")).c_str()) ;

その後いろいろとデバッガでやってみたが,その中は限定できなかった.
最適化の「実行速度」以外では,現象は発生しない.


結局 SP 6 をインストールすることに…
が,インストールできない.
VS 6 SP 6 was not completed successfully
対応方法がわからないので,仮想マシンの Win10 Pro x64 にインストールしてみるとうまくいった.
ちょっと面倒(ビルド時間がかかるなど)だが,動かないよりは良いので併用か?


2021/08/19
仮想マシンの VC 6 のデバッグ.
一度ブレークさせると,その後ステップ実行できない.

---------------------------
Microsoft Visual C++
---------------------------
Unhandled exception in GLSm.exe (OLE32.DLL): 0xC0000005: Access Violation.
---------------------------
OK   
---------------------------

VC 6 ブレーク後のステップ実行で 0xC0000005
同じタイミングでインストールした Win7 x64 環境ではうまく動作している.

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

JavaScript module Three.js

前回 Three.jsバージョンを更新 した時に気づいていたがそのままになっていたので少し調べてみた.
きっかけは,今まで r109 だったものを r131 にしようかと …
three.module.js は r83 ぐらい? example が module 対応になったのは r105 の頃か?
r105 と r106 の ./example/js/loaders/OBJLoader.js の内容は同じ.
./webgl_loader_obj_mtl.html は import 部分と THREE が異なる.JavaScript のコードとしては同じ?


次の所を参考に,いろいろと…
JavaScript モジュール
そこにある basic-modules を,import でない方法で書き直し.
main.js を html 内の body に取り込み.
最初,間違って head 内に書いたら create でエラー(document.body が null).
また,canvas.js 内に export が存在するとうまくいかず,js をコピーして,その行をコメントに.
script src=".../canvas_.js"
それを import を使用した方法に.
main.js を直接 body 内に記述したもの.
script type="module"


*.js をどちらの場合も同じものとしたいが,方法は?


2021/06/06
Three.js で,同じ OBJLoader.js を使っているのかと思ったが,違った.
example/js/OBJLoader.js と example/jsm/OBJLoader.js が存在している.


ある程度 module を使うための変更内容がわかったので,既存のデータを変更してみた.
データはいつもの.http://mish.work/i_Tools/Doc/blog/3D_Data/Cube_2021_07.htm
r109 を利用している.それを r131 に変更.
r131 に変更したもの
c_3js_10.js の先頭に次のもの追加.

import	* as THREE        	from '/_lib/js/webgl/threejs/r131/build/three.module.js';
import	{ OrbitControls } 	from '/_lib/js/webgl/threejs/r131/examples/jsm/controls/OrbitControls.js';
import	{ MTLLoader }     	from '/_lib/js/webgl/threejs/r131/examples/jsm/loaders/MTLLoader.js';
import	{ OBJLoader }     	from '/_lib/js/webgl/threejs/r131/examples/jsm/loaders/OBJLoader.js';

最後に以下を追加.

export	{	ThreeStart10	} ;
export	{	ThreeStartF 	} ;

html を type="module" と import …/c_3js_10.js に.

<script	type="module">
	import	{	ThreeStart10	}	from	"./c_3js_10.js" ;

type module , import
実行すると幾つかのエラー.

Uncaught TypeError: THREE.OrbitControls is not a constructor
    Set_orbit http://mish.work/i_Tools/Doc/blog/3D_Data/c_3js_10.js:137
    ThreeStart10 http://mish.work/i_Tools/Doc/blog/3D_Data/c_3js_10.js:47
    <anonymous> http://mish.work/i_Tools/Doc/blog/3D_Data/Cube_2021_08.htm:42

Uncaught TypeError: THREE.OrbitControls is not a constructor
OrbitControls などクラスの利用部分が違う.THREE. の部分を削除.
THREE. 部分を削除
module を使用した方法に変更
表示されている QR コードは,以前 WebGL が動作しない環境の時の区別のためのもの.
これはうまく使えないみたいなので,その部分は削除.他に “use strict”; なども削除.
module を使用


html の script の部分で type="module" が指定されていないと,

Uncaught SyntaxError: import declarations may only appear at top level of a module Cube_2021_08_E2.htm:19:3

type="module" が指定されていない時のエラー

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

コンソール AP で SetRegistryKey …

以前一度やっているが…
https://dev.mish.work/wordpress/2015/01/28/console-ap-reg-read/

class	CMy_App	:	public	CWinApp	{
public:
	void	SetRegistryKey_	(LPCTSTR key)	{	SetRegistryKey(key) ;	}
	} ;

//CWinApp	theApp ;
CMy_App		theApp ;

int	_tmain	(int argc,TCHAR* argv[])
{
	_tsetlocale(LC_ALL,_T("")) ;
	::reg_argv(argc,argv) ;
	{
		if (!AfxWinInit(::GetModuleHandle(NULL), NULL, ::GetCommandLine(), 0)) {
			std::terr << _T("Fatal Error: MFC initialization failed") << std::endl ;
			}
		theApp.SetRegistryKey_(Profile::GetRegKey_Base()) ;	//	レジストリを使用する
		}
	if (argc > 1) {
		for (int index=1 ; index<argc ; index++) {
			tstring	fold = argv[index] ;
			::test(fold) ;
			}
		}
	else {
		tstring	def_path = LPCTSTR(::PC_get_current_page()) ;
		tstring	fold = def_path ;
		while(true)	{
			fold = ::ask_folder(fold.c_str()) ;
			if (fold.empty())	{	break ;		}
			::test(fold) ;
			}
		}
	return	0 ;
	}

CMy_App SetRegistryKey

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

QR コード生成 – 3

今まで幾つかの所でサイトのアドレスの表示に使用してきた.
QRcode Perl CGI & PHP scripts ver. 0.50
これを他で使えないかと調べていると…

  1. 引数がうまく渡せない.2 つ目以降が無視されているような感じ.
  2. 100 文字位を超えると正しく表示できない.

どうも php の呼び出し方が悪かったみたいで,…/qr_img.php に与える引数を変更.

{
	p_data	=	p_data.substr(0,106) ;
	var	last_p	=	p_data.lastIndexOf('&') ;
	if (last_p > 0) {
		p_data	=	p_data.substr(0,last_p) ;
		}
	s_data	=	p_data ;
	p_data	=	escape		(p_data) ;
	p_data	=	"?d="	+	 p_data	;
//	p_data	=	p_data	+	"&e=M"	 ;
	}

使い方は以前と同様で .js のパスを変更.
<script src ="//itl.mydns.jp/_lib/js/i_lib/2022.01/c_qr_img.js"> </script>
<script> call_qr_img_href() ; </script>

<script src ="//itl.mydns.jp/_lib/js/i_lib/2022.01/c_qr_img.js"> </script>
<script> call_qr_img_href() ; </script>

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

XSS , OS Command Injection , …

2004/05 に VBScript で作成したサイト
その後何度か修正している.2005,2006,2007,2008,2010/01,2011/07,2015/03,2020/02,2020/06 .


幾つかの対応が必要なことは見つけたが,他のチェック内容がないかと思い見つけたサイト.
XSS フィルター回避チートシート
この中で明らかに引っかかったもの.
<SCRIPT SRC=http://ha.ckers.org/xss.js></SCRIPT>
表示されなくなった.
<IMG “””><SCRIPT>alert(“XSS”)</SCRIPT>”>
img script alert "XSS"


LAN 内で,過去のものもテストできる様に設定.

  1. ASP のあるフォルダ以下をコピー.
  2. Web サイトの追加.ポートはテスト用に 2015 など.ここまでで,//localhost:2015/ で表示はできる.
  3. ブラウザでエラーを表示するように設定.
  4. 32 ビットアプリケーションの有効化.
  5. LAN 内から表示できる様にする には,「Windows Definder ファイアウォール」の設定が必要.
    ファイアウォールでの設定
Is this 投稿 useful? Useful Useless 0 of 0 people say this 投稿 is useful.

NAS の証明書の更新

先日 Synology NAS の証明書の期限が切れてしまった.
DSM に入って「コントロールパネル」-「セキュリティ」-「証明書」タブ.
対象のものを「選択」して「右クリック」-「証明書を更新」で更新できる.
「証明書を更新」
以前は「自動更新」できていたが,mish.work を取っていろいろ設定したらうまく更新できなくなったみたい.


mish.work を取ってからは,それぞれの NAS で証明書を取る様に設定した.
今までのものは Synology NAS ,mish.work は QNAP NAS ,as.mish.work は ASUSTOR NAS .
今日 QNAP NAS を見ると自動で更新できたみたい.
QNAP NAS 証明書


これらをもう少しうまくできないものかと…
mish.work の関係を Synology NAS で取得しようとするがうまくいかない.
mish.work , *.mish.work の取得
QNAP NAS ではうまくいっているみたいなので,ds.as. のみにしてみたが変わらず.
IPv6 が反映されていない関係か?


2021/07/13
うまく取得できないのでしばらく様子見.

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

Fedora 34 で GLUT が動作しない?

仮想マシンの Fedora 32 を 34 に更新.
動作を確認していると,GLUT を使用した .out がうまく動作しない.
起動はしているが,ウィンドウが表示されない?
コンパイルなどはできている.
実行するとコンソールにはウィンドウを表示する前の部分は表示される.
いろいろやったがダメで,再起動.
Fedora 34 GLUT
うまく表示する様になった.

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

::GetDiskFreeSpaceEx , ::statvfs

Win9x が多く存在していた頃のコードの MFC を使用しない方法での書き直し.
前のものは次の様になっている.

//	J048221	SDK32:GetDiskFreeSpace と GetDiskFreeSpaceEx について
typedef BOOL (WINAPI *P_GDFSE)(LPCTSTR, PULARGE_INTEGER,PULARGE_INTEGER, PULARGE_INTEGER);
// ..
	fResult = ::GetDiskFreeSpace(pszDrive,&SectorsPerCluster,&BytesPerSector,&FreeClusters,&TotalClusters) ;
	if (fResult) {
		TotalBytes    	= (__int64)TotalClusters * SectorsPerCluster * BytesPerSector ;
		TotalFreeBytes	= (__int64)FreeClusters  * SectorsPerCluster * BytesPerSector ;
		FreeBytesAvailable = TotalFreeBytes ;
		}
// ..
{
	P_GDFSE	pGetDiskFreeSpaceEx = NULL;
	#ifdef UNICODE
		pGetDiskFreeSpaceEx = (P_GDFSE)GetProcAddress(GetModuleHandle(_T("kernel32.dll")),"GetDiskFreeSpaceExW") ;
	#else
		pGetDiskFreeSpaceEx = (P_GDFSE)GetProcAddress(GetModuleHandle(_T("kernel32.dll")),"GetDiskFreeSpaceExA") ;
	#endif
	if (pGetDiskFreeSpaceEx) {
		fResult = pGetDiskFreeSpaceEx (pszDrive,
			(PULARGE_INTEGER)&FreeBytesAvailable,
			(PULARGE_INTEGER)&TotalBytes,
			(PULARGE_INTEGER)&TotalFreeBytes);
		}
	}

J048221 SDK32:GetDiskFreeSpace と GetDiskFreeSpaceEx について
https://www.betaarchive.com/wiki/index.php?title=Microsoft_KB_Archive/231497


Windows 環境では次の様な感じ?

class	DiskFree	{
public:
	DiskFree ()	{	Free = Total = 0 ;	}
public:
	u_64	Free ;
	u_64	Total ;
	} ;

DiskFree	GetDiskFree	(LPCTSTR path)
{
	DiskFree	df ;
	u_64		freeC = 0 ;
	u_64		free  = 0 ;
	u_64		total = 0 ;
	if (::GetDiskFreeSpaceEx(path,(PULARGE_INTEGER)&freeC,(PULARGE_INTEGER)&total,(PULARGE_INTEGER)&free)) {
		df.Free = free ;
		df.Total= total;
		}
	return	df ;
	}

Linux 環境では ::statvfs が使えるみたいで,次の様なコードで取得してデバッガで確認.

#include    <iostream>
#include    <sys/statvfs.h>

int main()
{
	struct statvfs	vfs = { 0 } ;
	::statvfs(".", &vfs) ;
	return 0 ;
	}
vfs     	{...}           	statvfs
  f_bsize 	4096            	unsigned long
  f_frsize	4096            	unsigned long
  f_blocks	1452408524      	__fsblkcnt_t
  f_bfree 	200259802       	__fsblkcnt_t
  f_bavail	199469255       	__fsblkcnt_t
  f_files 	183001088       	__fsfilcnt_t
  f_ffree 	181248356       	__fsfilcnt_t
  f_favail	181248356       	__fsfilcnt_t
  f_fsid  	3941329918106335254	unsigned long
  f_flag  	4096            	unsigned long
  f_namemax	255             	unsigned long
  __f_spare	                 	int [6]
    [0]   	0               	int
    [1]   	0               	int
    [2]   	0               	int
    [3]   	0               	int
    [4]   	0               	int
    [5]   	0               	int

Debian10 ::statvfs

Iwao@AS5202T:/volume1/home/Iwao $ cd gcc_test/Test/t_linux/T_vfs/T_s_vfs/
Iwao@AS5202T:/volume1/home/Iwao/gcc_test/Test/t_linux/T_vfs/T_s_vfs $ ll
total 12
drwxrwxrwx    2 Iwao     users       4.0K Jul  1 22:01 ./
drwxrwxrwx    4 Iwao     users       4.0K Jul  1 22:00 ../
-rwxrwxrwx    1 Iwao     users        581 Jul  1 21:55 T_s_vfs.cpp*
Iwao@AS5202T:/volume1/home/Iwao/gcc_test/Test/t_linux/T_vfs/T_s_vfs $ cat T_s_vfs.cpp
#include    <iostream>
#include    <clocale>

#include    <sys/statvfs.h>

#include    "_tdefine.hxx"
#include    "t_tstrng.hxx"

int     _tmain  (int argc,TCHAR* argv[])
{
        _tsetlocale(LC_ALL,_T("")) ;
        {
                struct  statvfs vfs = { 0 } ;
                if (::statvfs(".", &vfs) == 0) {
                        u_64    free = vfs.f_bavail * vfs.f_frsize ;
                        u_64    total= vfs.f_blocks * vfs.f_frsize ;
                        std::tout << ::To_tstring_Ki(free) << _T(" / ") << ::To_tstring_Ki(total) << std::endl ;
                        std::tout << ::To_tstring_cs(free) << _T(" / ") << ::To_tstring_cs(total) << std::endl ;
                        }
                }
        return  0 ;
        }
Iwao@AS5202T:/volume1/home/Iwao/gcc_test/Test/t_linux/T_vfs/T_s_vfs $ g++ T_s_vfs.cpp -Wall
Iwao@AS5202T:/volume1/home/Iwao/gcc_test/Test/t_linux/T_vfs/T_s_vfs $ ./a.out
760.90 G /   5.41 T
817,005,420,544 / 5,949,065,314,304
Iwao@AS5202T:/volume1/home/Iwao/gcc_test/Test/t_linux/T_vfs/T_s_vfs $

AS5202T  ::statvfs
diskfree.hxx

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

NAS lxcdebian10 と VC 2019

ASUSTOR NAS 上の Debian と VC 2019 を使用してのビルドとデバッグ.
VC で次の様なエラーになっている.

lxcdebian10 にツールがありません: gdb rsync zip

lxcdebian10 にツールがありません: gdb rsync zip
次の所にある様に必要なものをインストール.
Linux development with C++ in Visual Studio
gdb rsync zip のインストール
丁度 1 年前にやっていた みたいで,その時より 安定したか?

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

C2535 , C2382

今まで特に問題なくビルドできていたプロジェクト.今月に入ってからは VC 2015 まででビルドしていた.

VC 2017
------ ビルド開始: プロジェクト: i3DV, 構成: Debug Win32 ------
C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\Common7\IDE\VC\VCTargets\Platforms\Win32\PlatformToolsets\v141_xp\Toolset.targets(39,5): warning MSB8051: Windows XP をターゲットとするサポートは非推奨であり、Visual Studio の将来のリリースで提供されなくなります。詳細については、https://go.microsoft.com/fwlink/?linkid=2023588 をご覧ください。
ComGui03.cpp
OpGL.hxx                    Support
Dbg.hxx Auto server      No Support
c:\program files (x86)\microsoft visual studio\2017\professional\vc\tools\msvc\14.16.27023\include\comip.h(152): error C2535: '_com_ptr_t<_IIID>::_com_ptr_t(int)': メンバー関数は、既に定義または宣言されています。
c:\program files (x86)\microsoft visual studio\2017\professional\vc\tools\msvc\14.16.27023\include\comip.h(141): note: '_com_ptr_t<_IIID>::_com_ptr_t' の宣言を確認してください
c:\program files (x86)\microsoft visual studio\2017\professional\vc\tools\msvc\14.16.27023\include\comip.h(938): note: コンパイル対象の クラス テンプレート インスタンス化 '_com_ptr_t<_IIID>' のリファレンスを確認してください
プロジェクト "i3DV141.vcxproj" のビルドが終了しました -- 失敗。
========== ビルド: 0 正常終了、1 失敗、0 更新不要、0 スキップ ==========
VC 2019
ビルドを開始しました...
------ ビルド開始: プロジェクト: i3DV, 構成: Debug Win32 ------
ComGui03.cpp
OpGL.hxx                    Support
Dbg.hxx Auto server      No Support
C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\VC\Tools\MSVC\14.29.30037\include\comip.h(115,5): error C2382: '_com_ptr_t<_IIID>::_com_ptr_t': 再定義 ; 異なる例外指定です。
C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\VC\Tools\MSVC\14.29.30037\include\comip.h(113): message : '_com_ptr_t<_IIID>::_com_ptr_t' の宣言を確認してください
C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\VC\Tools\MSVC\14.29.30037\include\comip.h(1096): message : コンパイル対象の クラス テンプレート インスタンス化 '_com_ptr_t<_IIID>' のリファレンスを確認してください
C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\VC\Tools\MSVC\14.29.30037\include\comip.h(381,10): error C2382: '_com_ptr_t<_IIID>::operator ==': 再定義 ; 異なる例外指定です。
C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\VC\Tools\MSVC\14.29.30037\include\comip.h(371): message : '_com_ptr_t<_IIID>::operator ==' の宣言を確認してください
C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\VC\Tools\MSVC\14.29.30037\include\comip.h(446,10): error C2382: '_com_ptr_t<_IIID>::operator !=': 再定義 ; 異なる例外指定です。
C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\VC\Tools\MSVC\14.29.30037\include\comip.h(436): message : '_com_ptr_t<_IIID>::operator !=' の宣言を確認してください
C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\VC\Tools\MSVC\14.29.30037\include\comip.h(511,10): error C2382: '_com_ptr_t<_IIID>::operator <': 再定義 ; 異なる例外指定です。
C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\VC\Tools\MSVC\14.29.30037\include\comip.h(501): message : '_com_ptr_t<_IIID>::operator <' の宣言を確認してください
C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\VC\Tools\MSVC\14.29.30037\include\comip.h(577,10): error C2382: '_com_ptr_t<_IIID>::operator >': 再定義 ; 異なる例外指定です。
C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\VC\Tools\MSVC\14.29.30037\include\comip.h(566): message : '_com_ptr_t<_IIID>::operator >' の宣言を確認してください
C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\VC\Tools\MSVC\14.29.30037\include\comip.h(643,10): error C2382: '_com_ptr_t<_IIID>::operator <=': 再定義 ; 異なる例外指定です。
C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\VC\Tools\MSVC\14.29.30037\include\comip.h(633): message : '_com_ptr_t<_IIID>::operator <=' の宣言を確認してください
C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\VC\Tools\MSVC\14.29.30037\include\comip.h(709,10): error C2382: '_com_ptr_t<_IIID>::operator >=': 再定義 ; 異なる例外指定です。
C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\VC\Tools\MSVC\14.29.30037\include\comip.h(699): message : '_com_ptr_t<_IIID>::operator >=' の宣言を確認してください
プロジェクト "i3DV142.vcxproj" のビルドが終了しました -- 失敗。
========== ビルド: 0 正常終了、1 失敗、0 更新不要、0 スキップ ==========

Win10 を 1909 から 20H2 に上げたのと,VS 2019 のアップデートがあった.
検索 をかけても,これといった情報には引っかからない.
となると,最近変更したコード?
nullptr を定義したことを思い出した.
#define nullptr NULL
VC 2015 以降では定義されない様に変更.
うまくいった.


nullptr は VC10 以降で使えるみたいで _MSC_VER < 1600 に変更.
https://ja.wikipedia.org/wiki/Microsoft_Visual_C++

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

C2664

スタックを使用した次の様なコード.

	stack_s	so ;

エラー情報を指定する様に変更してビルド.

	i_error	ie ;
	stack_s	so(&ie) ;
--------------------Configuration: t_stack - Win32 Debug--------------------
Compiling...
t_stack.cpp
d:\document\vs\vs\1998\t_stack\t_stack\t_stack.cpp(14) : error C2664: '__thiscall stack_s::stack_s(const class stack_s &)' : cannot convert parameter 1 from 'class i_error *' to 'const class stack_s &'
        Reason: cannot convert from 'class i_error *' to 'const class stack_s'
        No constructor could take the source type, or constructor overload resolution was ambiguous
Error executing cl.exe.

T_stack.exe - 1 error(s), 0 warning(s)

C2664 になってしまう.

class	stack_b	{
public:
		stack_b		(i_error* i_err=NULL)	{	ie = &tmp_ie ;	if(i_err != NULL) {	ie = i_err ;	}	}
protected:
	i_error		tmp_ie ;
	i_error*	ie ;
	} ;

class	stack_s	:	public	stack_b	{
public:
//		stack_s		(i_error* i_err=NULL)	:	stack_b	(i_err)		{	;	}
public:
	virtual	bool	push	(c_tstring& s) ;
	virtual	tstring	pop 	(void) ;
	virtual	tstring	last	(void) ;
protected:
	s_tstring	stck_s ;
	} ;

コメントにしている stack_s のコンストラクタを追加すれば OK .
C2664  stack
独習 C++ 7.3 223 ページ

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

SHBrowseForFolder

今度はフォルダの参照.
ダイアログを表示するだけの最低限のコード.

#include	<ShlObj.h>

bool	Test	(void)
{
	BROWSEINFO	bi	=	{	0	} ;
	LPITEMIDLIST	pidl	= ::SHBrowseForFolder(&bi) ;
	if (pidl == NULL)	{	return	false ;		}
	::CoTaskMemFree(pidl) ;
	return	true ;
	}

int	main	(void)
{
	while	(true)	{
		if (!Test()) {
			break ;
			}
		}
	return	0 ;
	}

SHBrowseForFolder VC 6
SHBrowseForFolder hwndOwner のみ指定
BROWSEINFO の hwndOwner も指定していないので動作がモードレスになってしまう.


SHBrowseForFolder のドキュメントを見ると IFileDialog FOS_PICKFOLDERS とある.


選択したフォルダ名を戻すように変更.

tstring	SH_GetPathFromIDList	(LPCITEMIDLIST pidl)
{
	tstring	path ;
	path.resize(MAX_PATH+10) ;
	BOOL	result = ::SHGetPathFromIDList(pidl,&path[0]) ;
	return	path.c_str() ;
	}

tstring	Test	(void)
{
	BROWSEINFO	bi	 =	{	0	} ;
	bi.ulFlags		|=	BIF_RETURNONLYFSDIRS ;
	bi.ulFlags		|=	BIF_NEWDIALOGSTYLE ;
	bi.ulFlags		|=	BIF_NONEWFOLDERBUTTON ;
	LPITEMIDLIST	pidl	 = 	::SHBrowseForFolder(&bi) ;
	if (pidl == NULL)	{	return	tstring() ;		}
	tstring	path = ::SH_GetPathFromIDList(pidl) ;
	::CoTaskMemFree(pidl) ;
	return	path ;
	}

pszDisplayName を指定すると,選択されたフォルダ名が返る.

	tstring		disp_name ;
	disp_name.resize(MAX_PATH) ;
	bi.pszDisplayName	 =	&disp_name[0] ;
//	...	SHBrowseForFolde
	std::tout << disp_name.c_str() << std::endl ;

初期フォルダ指定の追加.

int	CALLBACK	SH_BrowseCallback	(HWND hwnd,UINT uMsg,LPARAM lParam,LPARAM lpData)
{
	switch	(uMsg) {
		case	BFFM_INITIALIZED :
			::SendMessage(hwnd,BFFM_SETSELECTION,1,(LPARAM)(LPCTSTR)lpData) ;
			return	1 ;
			break ;
		default :
			return	0 ;
			break ;
		}
	return	0 ;
	}

{
//	...
	tstring		init_fold = init_fold_ ;
//	...
	bi.lpfn			 =	SH_BrowseCallback ;
	bi.lParam		 =	(LPARAM)init_fold.c_str() ;
	LPITEMIDLIST	pidl	 = ::SHBrowseForFolder(&bi) ;
//	...
	}

S_Browse.hxx
::Browse_Folder

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

Win10 に VS 6 インストール

今まで仮想マシンの WinXP で VC 6 を使用してきたが,ちょっと面倒なので Win10 環境に入れてみた.
使用したのは次の ISO .
en_visual_studio_6.0_professional_x86_dvd_224df581.iso
2021/04 に VS のダウンロードサイトで見つけた.
その時 Win7 環境などにインストールして動作することは確認済み.
Win7 に VS 6


インストール時,データベース関連を入れると止まると書かれていたので,外してインストール.
VB6開発環境をWindows 10にインストールする手順


VC 6 を簡単に確認した限りは何とか使えそう.


Win11 に VS 6 のインストール
Win11 22H2(デバッグできない時の設定も書いています)


2024/04/29
Win10 ,Win11 共に一部の制限があるものの VC 6 は特に問題なく使えている.

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

DS file にログインできない

先日までうまく使えていた DS file にログインできなくなってしまった.
DS file ログインできない


最近 Synology NAS に加えた変更は Synology Calendar を削除したこと.
その時一緒に WebDAV Server も削除した.
どうもこれがいけなかったみたい.
Synology NAS WebDAV Server
インストールして「実行」することでうまく動作する様になった.


2021/09
DSM 7 に更新してログインできなくなった場合は,DSM にログインする時と同様のポート番号を指定する.
DSM  7  DS file ログイン

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

OPENFILENAME

コンソール AP では,標準入力を使用していた.

#include	"quotm.hxx"
#include	"existff.hxx"

inline	bool	Test	(void)
{
	while(true)	{
		tstring	str ;
		{
			tstring	buf ;
			buf.resize(1000) ;
			std::terr << _T("file ...=") ;
			std::tin.getline(&buf[0],std::streamsize(buf.size())) ;
			str = buf.c_str() ;
			if   	(str == _T("q"))	{	break ;		}
			else if (str == _T("Q"))	{	break ;		}
			str = ::QuotM_Del_All(str) ;
			if (str.empty())   		{	continue ;	}
			}
		{
			if (::File_IsNothing(str)) 	{	continue ;	}
			std::tout << str << std::endl ;
			}
		}
	return	true ;
	}

int _tmain(int argc, TCHAR* argv[], TCHAR* envp[])
{
	{
		Test() ;
		}
	return	0 ;
	}

以前作成した CFileDialog を使用したもの.

#include	<afxwin.h>
#include	"F_Dialog.hxx"
#include	"quotm.hxx"

inline	bool	Test	(void)
{
	while(true)	{
		tstring	str ;
		{
			str = ::FD_GetOpenFile(_T("./")) ;
			if (str.empty())   		{	break ;		}
			}
		{
			if (::File_IsNothing(str))	{	continue ;	}
			std::tout << str << std::endl ;
			}
		}
	return	true ;
	}

CWinApp theApp;

int _tmain(int argc, TCHAR* argv[], TCHAR* envp[])
{
	int nRetCode = 0;
	if (!AfxWinInit(::GetModuleHandle(NULL), NULL, ::GetCommandLine(), 0)) {
		std::terr << _T("error : AfxWinInit") << std::endl ;
		nRetCode = 1;
		}
	else  {
		Test() ;
		}
	return nRetCode;
	}

////////////////////////////////////////////////////////////////////////////////////////

#include	<AfxExt.h>
#include	"BrowseFF.cxx"

「開く」ダイアログを表示するだけのコード.

{
	OPENFILENAME	ofn =	{	0	} ;
	ofn.lStructSize = sizeof(OPENFILENAME) ;
	if (!::GetOpenFileName(&ofn))	{	return	tstring() ;	}
//	...
	}

OPENFILENAME の指定が複雑なので,使いそうな内容でまとめてみた.

OPENFILENAME
lStructSize sizeof(OPENFILENAME)
hwndOwner NULL の時,モードレスになる.
CFileDialog では DoModal で求めている.
lpstrFile 選択されたファイル名が入る.
OFN_ALLOWMULTISELECT の場合は,下のメモリイメージ.
nMaxFile lpstrFile で確保している領域の文字数

OFN_ALLOWMULTISELECT の場合の結果の lpstrFile .

0x02C00078  44 3a 5c 44 6f 63 75 6d 65 6e 74 5c 56 53 5c 56  D:\Document\VS\V
0x02C00088  53 5c 32 30 30 35 5c 54 5f 4f 70 65 6e 46 5c 54  S\2005\T_OpenF\T
0x02C00098  5f 4f 46 5f 4d 46 43    54 5f 4f 46 5f 4d 46 43  _OF_MFC.T_OF_MFC
0x02C000A8  2e 42 41 4b    54 5f 4f 46 5f 4d 46 43 2e 63 70  .BAK.T_OF_MFC.cp
0x02C000B8  70    54 5f 4f 46 5f 4d 46 43 2e 76 63 70 72 6f  p.T_OF_MFC.vcpro
0x02C000C8  6a    54 5f 4f 46 5f 4d 46 43 2e 76 63 70 72 6f  j.T_OF_MFC.vcpro
0x02C000D8  6a 2e 5a 31 37 30 53 30 2e 49 77 61 6f 2e 75 73  j.Z170S0.Iwao.us
0x02C000E8  65 72       00 00 00 00 00 00 00 00 00 00 00 00  er..............

0x027E6B50  44 00 3a 00 5c 00 44 00 6f 00 63 00 75 00 6d 00 65 00 6e 00 74 00 5c 00 56 00 53 00 5c 00 56 00  D:\Document\VS\V
0x027E6B70  53 00 5c 00 32 00 30 00 30 00 35 00 5c 00 54 00 5f 00 4f 00 70 00 65 00 6e 00 46 00 5c 00 54 00  S\2005\T_OpenF\T
0x027E6B90  5f 00 4f 00 46 00 5f 00 4d 00 46 00 43 00 00 00 54 00 5f 00 4f 00 46 00 5f 00 4d 00 46 00 43 00  _OF_MFC.T_OF_MFC
0x027E6BB0  2e 00 42 00 41 00 4b 00 00 00 54 00 5f 00 4f 00 46 00 5f 00 4d 00 46 00 43 00 2e 00 63 00 70 00  .BAK.T_OF_MFC.cp
0x027E6BD0  70 00 00 00 54 00 5f 00 4f 00 46 00 5f 00 4d 00 46 00 43 00 2e 00 76 00 63 00 70 00 72 00 6f 00  p.T_OF_MFC.vcpro
0x027E6BF0  6a 00 00 00 54 00 5f 00 4f 00 46 00 5f 00 4d 00 46 00 43 00 2e 00 76 00 63 00 70 00 72 00 6f 00  j.T_OF_MFC.vcpro
0x027E6C10  6a 00 2e 00 5a 00 31 00 37 00 30 00 53 00 30 00 2e 00 49 00 77 00 61 00 6f 00 2e 00 75 00 73 00  j.Z170S0.Iwao.us
0x027E6C30  65 00 72 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  er..............

lpstrFile	0x02c10078 "D:\Document\VS\VS\2005\T_OpenF\T_OF_MFC\ReadMe.txt"	char *

デバッガで OPENFILENAME_SIZE_VERSION_400 となる様にしたもの.
OPENFILENAME_SIZE_VERSION_400


MFC 9 で bVistaStyle を FALSE とすると
CFileDialog bVistaStyle == FALSE
VC 8 exe と同様の,左側がフォルダツリーではない表示のもの.
デフォルトの TRUE だと
CFileDialog bVistaStyle == TRUE
COM を利用したもの?
Common Item Dialog


今度は MFC を使用しない方法.
::GetOpenFileName を使用する方法で OFN_ALLOWMULTISELECT を指定すると実行されなかった.
見た目のエラーにはならない?が,API を呼んで FALSE で抜けてくる.
::CommDlgExtendedError で調べると FNERR_INVALIDFILENAME だった.
存在しないファイル名などを与えるとうまくないみたい.
まだ何か足りないみたいで Win3.x 頃の表示になってしまった.
GetOpenFileName  Win3.x
選択したファイル名などもスペースで区切られている.
OFN_ALLOWMULTISELECT を指定する時は OFN_EXPLORER も指定する必要があるみたい.
次の所に書かれていた.
OPENFILENAMEW structure (commdlg.h)
OFN_ALLOWMULTISELECT | OFN_EXPLORER の場合 lpstrFile に存在しないファイル名でも問題なさそう.


複数選択可能な「開く」ダイアログのコードは次の様な感じ.

tstring	GetOpenFile	(LPCTSTR default_name=_T("./"))
{
	HWND	hwnd = ::GetConsoleHwnd() ;
	tstring	str_file = default_name ;
	    	str_file.resize(260*100) ;
	OPENFILENAME	ofn =	{	0	} ;
	{
		ofn.lStructSize	= sizeof(OPENFILENAME) ;
		ofn.hwndOwner	= hwnd ;
		ofn.nMaxFile	= DWORD(str_file.size()) ;
		ofn.lpstrFile	= &str_file[0] ;
		ofn.Flags   	= OFN_ALLOWMULTISELECT | OFN_EXPLORER | OFN_HIDEREADONLY ;
		}
	if (!::GetOpenFileName(&ofn)) {
		DWORD	err = ::CommDlgExtendedError() ;
		std::terr << ::To_tstring(u_32(err),16) << std::endl ;
		return	tstring() ;
		}
	tstring	sel_file ;
	{
		sel_file = ofn.lpstrFile ;
	//	...
		}
	return	sel_file ;
	}

拡張子のフィルタなどは指定していない.また,選択されたファイルを取得するコードもこれから.


選択されたファイルを取得するコード.

tstring	String_Change	(c_tstring& str_,const TCHAR src,const TCHAR dst)
{
	tstring	str = str_ ;
	for (size_t index=0 ; index<str.size() ; index++) {
		TCHAR	ch = str[index] ;
		if (ch == src) {
			str[index] = dst ;
			}
		}
	return	str ;
	}

	tstring	sel_file ;
	{
		sel_file = ofn.lpstrFile ;
		sel_file = str_file ;
		sel_file = ::String_Change(ofn.lpstrFile,_T('\x0'),_T('\n')) ;
		sel_file = ::String_Change(str_file,     _T('\x0'),_T('\n')) ;
		sel_file = ::String_TrimBoth(sel_file) ;
		}

ofn.lpstrFile は ASCIIZ となってしまうので,str_file をそのまま使用する必要がある.
Win3.x 形式の lpstrFile のダンプ.

0x02311F00  0043 003a 005c 0055 0053 0045 0052 0053 005c 0050 0055 0042 004c 0049 0043 005c  C.:.\.U.S.E.R.S.\.P.U.B.L.I.C.\.
0x02311F20  0044 004f 0043 0055 004d 0045 004e 0054 0053 005c 0020 0042 0061 0063 006b 0043  D.O.C.U.M.E.N.T.S.\. .B.a.c.k.C.
0x02311F40  0050 002e 0062 0061 0074 002e 006c 006e 006b 0020 0057 0049 004e 0031 0030 002d  P...b.a.t...l.n.k. .W.I.N.1.0.-.
0x02311F60  007e 0031 002e 004c 004e 004b 0020 005a 0031 0037 0030 0044 004f 007e 0031 002e  ~.1...L.N.K. .Z.1.7.0.D.O.~.1...
0x02311F80  004c 004e 004b 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000  L.N.K...........................

区切りがスペースになるため,ファイル名などにスペースが含まれている場合は 8.3 形式 になる.


lpstrFilter を指定.

	tstring	filter ;
		filter	+= _T("Executable Files (*.exe)|*.exe|") ;
		filter	+= _T("All Files (*.*)|*.*|") ;
		filter	+= _T("|") ;
		filter   = ::String_Change(filter,_T('|'),_T('\x0')) ;
	OPENFILENAME	ofn =	{	0	} ;
	{
		ofn.lStructSize	= sizeof(OPENFILENAME) ;
	//	...
		ofn.lpstrFilter	= &filter[0] ;
		}

ここまでのものを WinXP 環境で表示すると
GetOpenFileName WinXP


WFDialog.hxx

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

コンソール AP のウィンドウハンドル

GetOpenFileName を調べていて,コンソール AP のウィンドウハンドルが必要になった.
ofn.hwndOwner の NULL の指定では,モードレスの動作になってしまう.
CFileDialog は DoModal 内で設定していて,通常の AP であればうまく動作する様になっている.
CFileDialog DoModal hwndOwner
コンソール AP ウィンドウハンドル」で検索すると次のものがあった.
How to obtain a Console Window Handle (HWND)
そこにあったサンプルを,関数として抜き出し.
con_wnd.hxx


2023/08/02
2023/03 に ::GetConsoleWindow を使用したので,その関連のまとめ.
VC 7 以降,WinCon.h に ::GetConsoleWindow が追加されている.
VC 7 WinCon.h  ::GetConsoleWindow
それで,con_wnd.h では,VC 6 やそれ以降のものでもうまく通る様に変更している.

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

Win10 に GLUT インストール

2 年位前に Linux 環境 での GLUT はインストール した.
今回は Win10 環境に…


Windows GLUT」で検索すると…
なかなかうまく書かれているものが見つからない.
次の所は古いまま?
GLUT – The OpenGL Utility Toolkit
以前見た時は更新されていない様に思ったが…
freeglut
そこからのリンク
freeglut Windows Development Libraries
その中の freeglut 3.0.0 MSVC Package が欲しかったもの.


…/bin/freeglut.dll を c:\Windows\SysWOW64 にコピー.
また,glut32.dll の頃の exe も動作する様に …\SysWOW64\glut32.dll としてもコピー.
…/bin/x64/freeglut.dll は c:\Windows\System32 にコピー.
これで,以前作成した exe がそのまま動作することを確認.
glut32.dll  Pick05


glut.h と freeglut*.h は,次の …\PlatformSDK\include\gl にコピー.
VC 8 C:\Program Files (x86)\Microsoft Visual Studio 8\VC\PlatformSDK\Include\gl
VC 9 C:\Program Files\Microsoft SDKs\Windows\v6.0A\Include\gl
VC10 C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Include\gl
VC11 C:\Program Files (x86)\Windows Kits\8.0\Include\um\gl
VC12 C:\Program Files (x86)\Windows Kits\8.1\Include\um\gl
VC14 C:\Program Files (x86)\Windows Kits\8.1\Include\um\gl
VC141 C:\Program Files (x86)\Windows Kits\10\Include\10.0.19041.0\um\gl
VC142 C:\Program Files (x86)\Windows Kits\10\Include\10.0.19041.0\um\gl


freeglut.lib は次の所にコピー.
C:\Program Files (x86)\Microsoft Visual Studio 8\VC\PlatformSDK\Lib
C:\Program Files\Microsoft SDKs\Windows\v6.0A\Lib
C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Lib
C:\Program Files (x86)\Windows Kits\8.0\Lib\win8\um\x86 , x64
C:\Program Files (x86)\Windows Kits\8.1\Lib\winv6.3\um\x86 , x64
C:\Program Files (x86)\Windows Kits\10\Lib\10.0.19041.0\um\x86 , x64
freeglut でビルドしたもの


2021/12/24
glut.h と freeglut*.h,freeglut.lib のコピー先は,お使いの環境によって異なります.
10.0.19041.0 は 2021/05 の頃での設定によるものです.
2021/05 での freeglut*.h freeglut.lib
2021/12 では,10.0.22000.0 にコピーする必要があります.
2021/12 の SDK バージョン


https://itl.mish.work/Iwao/Doc/algo/to_thick/glut.htm


2023/11/02
VC インクルードパスの確認方法

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