2024年4月
 123456
78910111213
14151617181920
21222324252627
282930  

カテゴリー

アーカイブ

ブログ統計情報

  • 79,387 アクセス



DirectoryNotFoundException

以前作成した .NET の ZipFile クラス使用した exe
この iZIP.exe で System.IO.DirectoryNotFoundException .


原因は,ある環境でユーザ名に半角スペースが含まれていた.
ユーザ名に半角スペースを含む環境を作成して ZipFold.exe で同じ様な操作を行ったが,再現できない.
いろいろと調べていると,iZIP.exe に渡す時の入力のフォルダ名に半角スペースが含まれていると現象が発生する.

C:\Users\Iwao\AppData\Local\Temp\i_Tools.tmp\test>Q:\C_Temp\i_Tools\ZIP\iZIP\Release.140\iZIP.exe a "C:\Users\Iwao\AppData\Local\Temp\Send.tmp\20240416\09 22 39\" abc.zip

ハンドルされていない例外: System.IO.DirectoryNotFoundException: パス 'C:\Users\Iwao\AppData\Local\Temp\i_Tools.tmp\zip_CLI\20240416\154459\a' の一部が見つかりませんでした。
   場所 System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
   場所 System.IO.FileSystemEnumerableIterator`1.CommonInit()
   場所 System.IO.FileSystemEnumerableIterator`1..ctor(String path, String originalUserPath, String searchPattern, SearchOption searchOption, SearchResultHandler`1 resultHandler, Boolean checkHost)
   場所 System.IO.DirectoryInfo.EnumerateFileSystemInfos(String searchPattern, SearchOption searchOption)
   場所 System.IO.Compression.ZipFile.DoCreateFromDirectory(String sourceDirectoryName, String destinationArchiveFileName, Nullable`1 compressionLevel, Boolean includeBaseDirectory, Encoding entryNameEncoding)
   場所 ZipFile_create(Char* fld_file, Char* zip_name) 場所 c:\program files (x86)\microsoft visual studio 14.0\vc\include\xstring:行 1017
   場所 zip_create(basic_string<wchar_t\,std::char_traits<wchar_t>\,std::allocator<wchar_t> >* , Char* zip_root) 場所 t:\develop\_.src\__mlt_\zip_func.hxx:行 47
   場所 zip_create(Char* fld_file, Char* zip_name) 場所 t:\develop\_.src\__mlt_\zip_func.hxx:行 143
   場所 call_func(Int32 argc, Char** argv) 場所 c:\program files (x86)\microsoft visual studio 14.0\vc\include\xstring:行 521
   場所 wmain(Int32 argc, Char** argv) 場所 l:\document\develop\tools\_free\ziptools\izip\izip.cpp:行 168
   場所 _wmainCRTStartup()

C:\Users\Iwao\AppData\Local\Temp\i_Tools.tmp\test>Q:\C_Temp\i_Tools\ZIP\iZIP\Release.140\iZIP.exe a "C:\Users\Iwao\AppData\Local\Temp\Send.tmp\20240416\09 22 39\" ".\20240416\1545\abc.zip"

ハンドルされていない例外: System.IO.DirectoryNotFoundException: パス 'C:\Users\Iwao\AppData\Local\Temp\i_Tools.tmp\zip_CLI\20240416\154602\a' の一部が見つかりませんでした。
   場所 System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
   場所 System.IO.FileSystemEnumerableIterator`1.CommonInit()
   場所 System.IO.FileSystemEnumerableIterator`1..ctor(String path, String originalUserPath, String searchPattern, SearchOption searchOption, SearchResultHandler`1 resultHandler, Boolean checkHost)
   場所 System.IO.DirectoryInfo.EnumerateFileSystemInfos(String searchPattern, SearchOption searchOption)
   場所 System.IO.Compression.ZipFile.DoCreateFromDirectory(String sourceDirectoryName, String destinationArchiveFileName, Nullable`1 compressionLevel, Boolean includeBaseDirectory, Encoding entryNameEncoding)
   場所 ZipFile_create(Char* fld_file, Char* zip_name) 場所 c:\program files (x86)\microsoft visual studio 14.0\vc\include\xstring:行 1017
   場所 zip_create(basic_string<wchar_t\,std::char_traits<wchar_t>\,std::allocator<wchar_t> >* , Char* zip_root) 場所 t:\develop\_.src\__mlt_\zip_func.hxx:行 47
   場所 zip_create(Char* fld_file, Char* zip_name) 場所 t:\develop\_.src\__mlt_\zip_func.hxx:行 143
   場所 call_func(Int32 argc, Char** argv) 場所 c:\program files (x86)\microsoft visual studio 14.0\vc\include\xstring:行 521
   場所 wmain(Int32 argc, Char** argv) 場所 l:\document\develop\tools\_free\ziptools\izip\izip.cpp:行 168
   場所 _wmainCRTStartup()

C:\Users\Iwao\AppData\Local\Temp\i_Tools.tmp\test>

iZIP.exe  System.IO.DirectoryNotFoundException
入力のフォルダ名の “…\20240416\09 22 39\” の “09 22 39” 直後の ‘\’ を削除するとうまくいく.


デバッガで iZIP.exe に渡されるコマンドラインを確認.
iZIP.exe コマンドライン引数
デバッグ時,ダンプする様にコードを書換え.
iZIP.exe コマンドライン引数のダンプ
やはり argv がうまく解釈されていない.
argv[2]が「…\17 53 06″ c:\…」となってしまっている.
“…\17 53 06\\” の様にすれば通ることは確認できた.
perse_commandline では ‘\”‘ がダブルクォーテーションと解釈され,’\\’ はバックスラッシュ?


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

「引数が正しくありません」

以前に書いた情報を整理.
Win10 21H1 でうまく動作しない exe
Win10 環境で,MDI exe にドキュメントをドロップすると「引数が正しくありません」となることがある.


原因は ::CoInitinalize が呼び出されていないため.
コードでの対応方法としては InitInstance の最初に以下を追加.

	// OLE ライブラリを初期化します。
	if (!AfxOleInit()) {
		AfxMessageBox(_T("OLE の初期化に失敗しました。")) ;
		return	FALSE ;
		}

また,一度「開く」ダイアログを表示すると,その後は問題ない.

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

SSL 証明書の更新ができない?

以前から安定しない気がする証明書の更新
うまく更新できることも多くなったとは思うが,手動で行うとうまくないことがある.
ASUSTOR NAS  Let's Encrypt
今までは,ルータの「ポートフォワーディング」で 80 を対象の NAS に変更して対応できていた.
それが,今日はうまくいかない.
外から http://27.92.169.109 にアクセスすると,別の Web サーバのままで,対象の NAS に転送されない.


ルータを再起動することで,うまく転送され,証明書の更新もできた.

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

VirusTotal Trojan 472047

最近 ViruaTotal で,VC 2022 ビルドの exe が引っ掛かる様になった気がする.

Antiy-AVL          GrayWare/Win32.Wacapew
Arcabit            Trojan.Lazy.D733EF [many]
BitDefender        Gen:Variant.Lazy.472047
Emsisoft           Gen:Variant.Lazy.472047 (B)
GData              Gen:Variant.Lazy.474792
MAX                Malware (ai Score=87)
MaxSecure          Trojan.Malware.121218.susgen
McAfee             GenericRXWN-PP!71DE1C7042EF
Rising             Trojan.Generic@AI.83 (RDML:km3T2NBP/pqn91WCd2xwaA)
Skyhigh (SWG)      GenericRXWN-PP!71DE1C7042EF
Trellix (FireEye)  Gen:Variant.Lazy.472047
VIPRE              Gen:Variant.Lazy.472047

VirusTotal   Trojan  472014
VC 2015 や 2017 でビルドしたものはほぼ大丈夫だが,2019 や 2022 ではうまくない.
また,以前は検出されなかったものが,引っ掛かる様になったものもある.
誤検知と思われるが,どうしたものか…

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

プレーン テキスト フィルター ?

Windows Search でインデックスを作成するために,
[HKEY_CLASSES_ROOT\.(ext)\PersistentHandler]
@="{5E941D80-BF96-11CD-B579-08002B30BFEB}"

[HKEY_CURRENT_USER\SOFTWARE\Classes\.(ext)\PersistentHandler]
@="{5E941D80-BF96-11CD-B579-08002B30BFEB}"


いろいろ試したが,HKLM 以下が必要?
[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\.(ext)\PersistentHandler]
@="{5E941D80-BF96-11CD-B579-08002B30BFEB}"
反映される(インデックスが作成される)までに時間がかかるのでよくわからない.
プレーン テキスト フィルター
確実なのは「プレーン テキスト フィルター」に設定して,「インデックスの設定」タブの「再構築」か?


ネットワーク上のファイルも検索できるみたいだが…
検索場所を指定して「 *.txt MICROSOFT FOUNDATION CLASS LIBRARY 」.
「 *.txt MICROSOFT FOUNDATION CLASS LIBRARY 」で検索
ネットワークドライブとして割り当てると検索できる?
検索されるまで時間がかかるのと,サーバにより?うまく検索できないことがある.
Win10 環境で 「 *.txt MICROSOFT FOUNDATION CLASS LIBRARY 」

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

msi でインストールを実行できない

Win10 環境に msi でインストールしようとすると…
[Window Title]
Windows インストーラー
[Main Instruction]
システム管理者によって、ポリシーはこのインストールを実行できないように設定されています。
[OK]
Windows インストーラー
システム管理者によって、ポリシーはこのインストールを実行できないように設定されています。
検索すると「ローカルセキュリティポリシー」の設定などが見つかる.
ローカルセキュリティポリシー
他の Win10 を確認すると,同様に定義されていない.
この現象の環境は Windows Update があり,その更新後起動した状態のもの.


ポリシーを追加しようかと思ったが,念のため一度再起動.
すると,何もなかったかの様にインストールできる様になった.
何だったのだろう.


2024/04/17
また同じ現象に.
今度は,再起動する前に幾つかの exe を終了しながら確認.
ブラウザなど,メモリをそこそこ食っているものを終了.これは変わらずインストールできない.
「エクスプローラー」の「このディスプレイのすべてのウィンドウを閉じる」でインストールできる様になった.

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

NAS 証明書のインポート

ASUSTOR NAS から,証明書の更新ができなかったメールが来ていた.

This is a system event notification sent from AS5202T.
Event Level: WARNING
Date: 2024/02/09 00:00
User: SYSTEM
Event: [Certificate Manager] Authentication for as.mish.work failed.

https://dev.mish.work/wordpress/2022/08/13/authentication-for-failed/
うまく更新できることもあったと思うが,ルータの設定で 80 が対象の NAS へ転送される様に設定して手動で更新.
ルータの「ポートフォワーディング」の設定で 80 を対象の NAS に転送


Synology NAS の証明書の所を見ると QNAP NAS の期限も迫っている.
QNAP NAS の証明書を見ると,こちらはちゃんと更新されている.
それをエクスポートして,Synology NAS でインポート.
インポートする手順は「証明書」タブの「追加」.
「既存の認証を置き換えます」を選んでドロップダウンから対象のものを選択.
「証明書」の「追加」,「既存の認証を置き換えます」
「次へ」を押して「証明書のインポート」を選択して「次へ」.
「証明書のインポート」
「秘密キー」と「証明書」などを指定して「OK」で更新できる.

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

AppName.ini

何年か前に作成したツールをビルドしていて,ちょっと気になったこと.
exe 名を変更した時,設定値がうまく引き継がれない.
レジストリを使用している時は AFX_IDS_APP_TITLE を追加すれば良いが ini では効果がない.
CWinApp::SetCurrentHandles()    m_pszProfileName


最近書いたコードからは,次の様に m_pszProfileName を変更する様にしている.

BOOL	RI_Set_ProfileName		(void)
{
	CWinApp*	app = AfxGetApp() ;
	if (app == NULL)    	{	return	FALSE ;		}
	CString		nowINI = app->m_pszProfileName ;
	CString		newINI = ::INI_get_module_ini().c_str() ;
	if (nowINI == newINI)	{	return	TRUE ;		}
	free((void*)app->m_pszProfileName) ;
	app->m_pszProfileName = _tcsdup(newINI) ;
	{
		std::tout << _T("org=") << LPCTSTR(nowINI) << std::endl ;
		std::tout << _T("new=") << LPCTSTR(newINI) << std::endl ;
		}
	return	TRUE ;
	}
Is this 投稿 useful? Useful Useless 0 of 0 people say this 投稿 is useful.

ダイアログベース コマンドライン

ファイルの関連付けを調べていて,3D データを表示するツールに関連付けるとうまく表示されない.
MFC ダイアログベースのスケルトンでは,コマンドラインの標準的な処理は入っていない.


それで OnInitDialog の最後の方で次の様にした.

{
	CStringArray	readFiles ;
	for (int a_index=1 ; a_index<__argc ; a_index++) {
		CString	av = __targv[a_index] ;
		readFiles.Add(av) ;
		}
	if (readFiles.GetSize() > 0) {
		ReadFiles(readFiles) ;
		}
	}

S_asZ  2024.01


更に,幾つかのツールでうまく開けないものがあった.
InitInstance での初期化手順がうまくなかった.
i3DV  App  InitInstance

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

ADM 4.2.6.ROR2 IPv6

ASUSTOR NAS の ADM の更新版があったので更新.


更新後,ブラウザでアクセスすると…
LAN 内の PC から as.mish.work にアクセスできない.
IP では可能.mish.myasustor.com も OK .
4G 回線を使用したスマートフォンからのアクセスは可能.


IPv6 でのアクセスができなくなっている?
http://[240f:33:c6c7:1:12bf:48ff:fe8d:50ab]/
ADM 4.2.ROR2  IPv6
アドレスが変わってしまっている.
リリースノートを読むと,確かに書いてあった.
* IPv6 アドレスのプライバシーとセキュリティを強化するために、IPv6 アドレス生成メカニズムを変更しました。
AAAA レコードを更新して対応.
1 時間程経って as.mish.work にアクセスできる様になった.

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

引数が正しくありません

ツールチップの表示内容に幾つかの情報を追加してテストしていると…
—————————
xxxxxxxx
—————————
引数が正しくありません。
—————————
OK
—————————
引数が正しくありません
デバッガで追いかけると MAX_TIP_TEXT_LENGTH の制限を超えていた.
CToolTipCtrl::UpdateTipText
呼び元で超えない様にカットして対応.

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

フォルダの更新日時の設定

以前に作成した mtime を更新するツール
データファイルなどの更新日時を揃えるために作成したもの.
更新日時の設定は CFile::SetStatus で行っている.

	CString		file = UpdateFiles[index] ;
	CFileStatus	fs ;
	CFile::GetStatus(file,fs) ;
	fs.m_mtime = newTime ;
	CFile::SetStatus(file,fs) ;

このツールではフォルダの更新日時は変更できない.


その後 Linux 環境などでも動作する様なコードを作成
utime を使用したもの.
Linux 環境ではフォルダに対してもうまく動作するが,Windows 環境では相変わらず.
DS220  utime
ここまでは,以前調べたもの


2ヶ月ほど前だったと思うが,検索していて次のページを見つけた.
ファイル・フォルダーの更新日時を変更


改めて CFile::SetStatus や _utime の中身を見ると,動作は同じで ::CreateFile と ::SetFileTime を呼出している.
デバッガで追いかけていると ::CreateFile で失敗している.errno は 13 .
::CreateFile を次の様に指定して呼出すと,ファイルの場合は問題ないがフォルダは NG .

HANDLE  hFile = ::CreateFile(file_name,GENERIC_READ|GENERIC_WRITE,0,NULL,OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL,     NULL) ;

フォルダの場合 FILE_FLAG_BACKUP_SEMANTICS が指定されていなければならないみたい.

HANDLE  hFile = ::CreateFile(file_name,GENERIC_READ|GENERIC_WRITE,0,NULL,OPEN_EXISTING,FILE_FLAG_BACKUP_SEMANTICS,NULL) ;

time_t から FILETIME への変換は次の所.
https://learn.microsoft.com/ja-jp/windows/win32/sysinfo/converting-a-time-t-value-to-a-file-time
SetFTime.hxx

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

.INI に更新されない?

個人的なツールなどでレジストリを汚したくないために .ini を使用している.
今回個人的な ProtectT クラスを書き直してテストしているとうまく動作しない.
該当コードの単体テストではうまく通るが,ツールに組込んで動作させるとうまくいかないことがある.
コードの内容としては,共通の i_Tools.ini と AP.ini に同じ値を更新していて,それを読みだした時に値が異なっていた.


i_Tools.ini は他の AP からも読み書きしている.
タイミングによって,うまく更新できないことがある?
文字の立体化
ProtectT の i_Tools.ini へアクセスするコードを見直して,極力書き込みを減らすようにした.
また,読み込み時,値が意図したものと異なる場合は AP.ini の方を利用する様にした.
これで今回の部分は対応できていると思うが,他の既存部分ではまだ問題がありそう.


次の様なコードで確認すると,やはり書けないことがある様子.

	{
		#define	Sec_test  _T("_test_")
		#define	Ent_test  _T("_test_")
		RI_app	app ;
		RI_env	env ;
		for (long index=0 ; index<500 ; index++) {
			if (index%10 == 0)	{	std::tout << std::endl ;	}
			std::tout << index << _T("\t") ;
			std::tout << app.set(Sec_test,Ent_test,index) ;	std::tout << _T("  ") ;
			std::tout << env.set(Sec_test,Ent_test,index) ;	std::tout << _T("\t") ;
			long	val_a = app.get(Sec_test,Ent_test,-1) ;
			long	val_e = env.get(Sec_test,Ent_test,-2) ;
			if (val_a != val_e) {
				std::tout << std::endl ;
				std::tout << val_a << _T("\t") << val_e << std::endl ;
				::Sleep(1000) ;
				break ;
				}
			::Sleep(10) ;
			}
		std::tout << std::endl ;
		return	true ;
		}

env.set(…) は,内部的に ::WritePrivateProfileString を呼出していて 0 が返っている.
::WritePrivateProfileString


最初現象を簡単には再現できなかったが,エクスプローラのサムネイル表示を行っていると発生しやすい.
また,今回のテスト用 exe が止まってしまうこともあった.開いているエクスプローラをすべて閉じることで解消.
シェルエクステンションのコードの見直しが必要か?


ini への書き込み部分を次の様に変更.

//	return	(     ::WritePrivateProfileString(sec,ent,val,ini)==TRUE) ;
	BOOL	res = ::WritePrivateProfileString(sec,ent,val,ini) ;
	if (!res)	{
		std::terr << _T("::WritePrivateProfileString ")	<< sec << _T(" ") << ent << _T(" ") << ::GetLastError() << std::endl ;
		for (size_t index=0 ; index<10 ; index++) {
			res = ::WritePrivateProfileString(sec,ent,val,ini) ;
			if (res)	{	break ;		}
			::Sleep(10) ;
			}
		}
	return	(res==TRUE) ;

::GetLastError() では 32 ERROR_SHARING_VIOLATION が返ってくる.

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

error C2144 , C2501

ビルドしていると

--------------------Configuration: TToPA - Win32 Release--------------------
Compiling...
TToPADlg.cpp
C:\Program Files (x86)\Microsoft Visual Studio\VC98\INCLUDE\gl/gl.h(23) : error C2144: syntax error : missing ';' before type 'int'
C:\Program Files (x86)\Microsoft Visual Studio\VC98\INCLUDE\gl/gl.h(23) : error C2501: 'c' : missing storage-class or type specifiers
C:\Program Files (x86)\Microsoft Visual Studio\VC98\INCLUDE\gl/gl.h(23) : fatal error C1004: unexpected end of file found
Error executing cl.exe.

TToPA.exe - 3 error(s), 0 warning(s)

error C2144 , C2501
ファイルの先頭に “c” の文字が入力されてしまっていた.
デバッグしていて,何かの拍子に “c” が入ってしまったことに気づかなかった.
バックアップしてあったファイルを戻して対応.

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

error C2062 , C2065

先日作成した,レジストリなどのアクセスのコード
それを使用しているコードを VC 2015 環境でビルドすると…

1>------ ビルド開始: プロジェクト:S_asZ, 構成:Debug Win32 ------
1>t:\develop\_.src\__win\ri_env.hxx(67): error C2062: 型 'bool' は不要です。
1>t:\develop\_.src\__win\ri_env.hxx(69): error C2065: 'res': 定義されていない識別子です。
1>t:\develop\_.src\__win\ri_env.hxx(70): error C2065: 'res': 定義されていない識別子です。
1>t:\develop\_.src\__win\ri_env.hxx(72): error C2065: 'res': 定義されていない識別子です。
1>t:\develop\_.src\__win\ri_env.hxx(78): error C2062: 型 'bool' は不要です。
1>t:\develop\_.src\__win\ri_env.hxx(80): error C2065: 'res': 定義されていない識別子です。
1>t:\develop\_.src\__win\ri_env.hxx(81): error C2065: 'res': 定義されていない識別子です。
1>t:\develop\_.src\__win\ri_env.hxx(83): error C2065: 'res': 定義されていない識別子です。
1>t:\develop\_.src\__win\ri_env.hxx(133): error C2062: 型 'bool' は不要です。
1>t:\develop\_.src\__win\ri_env.hxx(135): error C2065: 'res': 定義されていない識別子です。
1>t:\develop\_.src\__win\ri_env.hxx(136): error C2065: 'res': 定義されていない識別子です。
1>t:\develop\_.src\__win\ri_env.hxx(138): error C2065: 'res': 定義されていない識別子です。
========== ビルド: 0 正常終了、1 失敗、0 更新不要、0 スキップ ==========

error C2062: 型 'bool' は不要です。
今まで OpenMP が動作しない状態でのビルドだったので気づかなかった.
#ifdef _OPENMP … #endif の位置が違っていた.

bool	set_DW	(LPCTSTR sec,LPCTSTR ent,const u_32 val)    {
    bool	res = false ;
    #ifdef	_OPENMP
        #pragma	omp	critical	(RI_app_set_DW)
    #endif
    {
        if (Use_reg)	{    REG_get_sec_key(sec) ;	res = RI_rkey.set_DW(         ent,val) ;    }
        else       	{                          	res = ::  INI_set(NameINI,sec,ent,val) ;    }
        }
    return	res ;
    }

bool res = false を #ifdef の前に持ってきて対応.

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

error C2666: ‘get’ : 8 overloads …

次の様なコードをコンパイルすると,「error C2666: ‘get’ : 8 のオーバーロード関数があいまいです。」

{
	#define	SecProtectT	_T("Debug")
	RI_app	CountP ;
	RI_env	CountC ;
	tstring	exe_title = ::Path_GetTitle(::RI_get_module_name()) ;
	time_t	nowTime = ::time(NULL) ;
	time_t	countP_ = time_t(CountP.get(SecProtectT,exe_title.c_str(),i_32(nowTime))) ;
	time_t	countC_ = time_t(CountC.get(SecProtectT,exe_title.c_str(),i_32(nowTime))) ;
	time_t	countPT = time_t(CountP.get(SecProtectT,exe_title.c_str(),i_64(nowTime))) ;
	time_t	countCT = time_t(CountC.get(SecProtectT,exe_title.c_str(),i_64(nowTime))) ;
	}
--------------------構成: PrtctT - Win32 Debug--------------------
コンパイル中...
PrtctT.cpp
l:\document\develop\tools\_yet\_other\key2013\prtctt\prtctt.cpp(110) : error C2666: 'get' : 8 のオーバーロード関数があいまいです。(新しい機能 ; ヘルプを参照)
l:\document\develop\tools\_yet\_other\key2013\prtctt\prtctt.cpp(110) : fatal error C1903: 直前のエラーを修復できません; コンパイルを中止します。
cl.exe の実行エラー
PrtctT_d.exe - エラー 2、警告 0

error C2666: 'get' : 8 のオーバーロード関数があいまいです。
次のメンバ関数を追加したことによる影響だったが,RI_app でエラーになっていないのがよくわからない.
i_32 get (c_tstring& sec,c_tstring& ent,const i_32 def) { … }
次の LPCTSTR 形式のメンバ関数を追加して対応.
i_32 get (LPCTSTR sec,LPCTSTR ent,const i_32 def) { … }

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

#pragma omp critical

共通のリソースに対してのコードを書いていて,ちょっと気になったので調べてみた.
テスト用に書いたのコードは次の様なもの.

#ifdef		_OPENMP
#include	<omp.h>
#endif

#include	<clocale>
#include	<iostream>

#ifdef	_MSC_VER
	#include	<tchar.h>
#else
	#define		 _T(x)			x
	typedef		char			TCHAR ;
#endif

#ifdef	_UNICODE
	#define		_tmain			wmain
	#define		tout			wcout
#else
	#define		_tmain			main
	#define		tout			cout
#endif

bool	test_n	(const long n)
{
	std::tout << _T("test_") << n << _T("\t") ;
	{
		for (long index=0 ; index<10 ; index++) {
			#ifdef	_OPENMP
			//	#pragma	omp	critical	//	(test)		//	--- (C)
			#endif
			{
				std::tout << (n*10 + index+1) << _T("\t") ;
				}
			}
		}
	return	true ;
	}

bool	test_	(void)
{
	std::tout << _T("test_") << std::endl ;
	{
		#ifdef	_OPENMP
			#pragma	omp	parallel for
		#endif
		for (long index=0 ; index<10 ; index++) {
			#ifdef	_OPENMP
				#pragma	omp	critical	//	(test)		//	--- (P)
			#endif
			{
				test_n(index) ;
				std::tout << std::endl ;
				}
			}
		}
	return	true ;
	}

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

実行させると,期待通り.
#pragma omp critical


ここで,関数 test_n() の次の行を有効にしてしまうと…
#pragma omp critical // (test) // — (C)
test_
test_0 致命的なユーザー エラー 1002: 同一名の 1 つで ‘#pragma omp critical’ が不適切に入れ子にされています
致命的なユーザー エラー 1002: 同一名の 1 つで '#pragma omp critical' が不適切に入れ子にされています
それぞれを異なる名称で指定する必要がある.
#pragma omp critical (test_n) // — (C)
#pragma omp critical (test_) // — (P)
#pragma omp critical 異なる名称
VC リリース版ではうまく動作してしまうこともある?


Linux 環境でコンパイルした a.out を NAS 環境に持っていくと,DS220+ では実行できた.
-fopenmp を付けたコンパイルは不可
TS253D では「libgomp.so がない」となって実行できない.
OpenMP  a.out の NAS での実行

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

VERR_UNRESOLVED_ERROR

Win11 上の仮想マシン Mint を起動しようとすると,
VM Name: Mint
Unresolved (unknown) host platform error. (VERR_UNRESOLVED_ERROR).
Result Code:
E_FAIL (0X80004005)
Component:
ConsoleWrap
Interface:
IConsole {6ac83d89-6ee7-4e33-8ae6-b257b2e81be8}
VirtualBox VERR_UNRESOLVED_ERROR
検索しても該当しそうなものがわからない.
多く見つかるのは,Hyper-V などの無効化.


PC を再起動させよう思い,他の仮想マシンを「保存」して,試しに Mint を起動するとうまく起動した.
それで,「保存」した他の仮想マシンを起動しようとすると同様のエラーに.
こうなると,システムリソースの問題と思い,プロセッサ数を減らすが効果はない.
次にメモリ量を減らしてうまく起動した.
先日作成した WS 2019 のメモリ量を 6G から 4G にして運用することにした.
VirtualBox  Mint


Mint 環境でコンパイルできる様に,共通のコードを参照するための mount .
/mnt/_.src を作成して,Fedora 環境にあった .sh をコピー.が,エラーとなる.
以前やった時を見直すと,IP で指定しないとうまくいかないことがあった
.sh を書き換えてうまくいった.
Mint   mount  IP

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

C2440: ‘return’ : cannot convert …

以前,iniレジストリ を操作する関数を作成した.
それで,少しずつ書き換えていると…

--------------------Configuration: PrtctT - Win32 Debug--------------------
Compiling...
PrtctT.cpp
t:\develop\_.src\__win\ri_reg.hxx(383) : error C2440: 'return' : cannot convert from 'class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >' to 'int'
        No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called
        l:\document\develop\tools\_yet\_other\key2013\prtctt\prtctt.cpp(162) : see reference to function template instantiation 'int __cdecl REG_get(struct HKEY__ *,const class std::basic_string<char,struct std::char_traits<char>,class std::allocato
r<char> > &,const class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > &,const int &)' being compiled
Error executing cl.exe.

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

通常の関数であればうまく機能すると思うが…
関数 template は難しい.
error C2440: 'return' : '...' から 'int' に変換することはできません。
コメントにしている部分で書き換えれば OK .

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

Windows C++ __argc __argv

MFC でコードを書いていて,コマンドライン引数を取りたくなった.
MFC では次の様にすれば取れるが,欲しいのは c の main に渡される argc と argv .
CString cmd_line = AfxGetApp()->m_lpCmdLine ;
検索すると次の所があった.欲しかった情報は __argc と __argv
【 VC++ MFC 】MFC でコマンドライン引数を利用する方法
次の様なコードを書いて動作を確認.

#include	<clocale>
#include	<iostream>
#include	<tchar.h>

#ifdef	_UNICODE
	#define		tin 		wcin
	#define		tout		wcout
	#define		terr		wcerr
	#define		tlog		wclog
#else
	#define		tin 		cin
	#define		tout		cout
	#define		terr		cerr
	#define		tlog		clog
#endif

int	_tmain	(int ,TCHAR* )
{
	_tsetlocale(LC_ALL,_T("")) ;
	{
		std::tout   		<< __argc      	<< std::endl ;
		for (int index=0 ; index<__argc ; index++) {
			std::tout	<< __targv[index]	<< std::endl ;
			}
		}
	return	0 ;
	}

Windwos C コマンドライン引数
_tmain が呼び出される前の mainCRTStartup の ::_setargv で設定されている.
::_setargv

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