ホーム » 検索結果: C++/CLI

検索結果: C++/CLI

2024年3月
 12
3456789
10111213141516
17181920212223
24252627282930
31  

カテゴリー

アーカイブ

ブログ統計情報

  • 77,436 アクセス



.NET ZipFile C++/CLI

ZipFile クラスのサンプル を C++/CLI で.
Win32 コンソール AP としてプロジェクトを作成.
CPP を次の様に変更.

#include	<stdio.h>
#include	<tchar.h>

//	using	System;
//	using	System.IO.Compression;
#using  	<System.dll>
#using		<System.IO.Compression.FileSystem.dll>

//	class Program
//	{
//		static void Main(string[] args)
//		{

int _tmain(int argc, _TCHAR* argv[])
{
//			string  startPath	= @"./start";
//			string  zipPath  	= @"./result.zip";
//			string  extractPath	= @"./extract";
		System::String^	startPath	= _T("./start") ;
		System::String^	zipPath  	= _T("./result.zip") ;
		System::String^	extractPath	= _T("./extract") ;

//		                         ZipFile. CreateFromDirectory(startPath, zipPath);
		System::IO::Compression::ZipFile::CreateFromDirectory(startPath, zipPath);

//		                         ZipFile. ExtractToDirectory(zipPath, extractPath);
		System::IO::Compression::ZipFile::ExtractToDirectory(zipPath, extractPath);

	return 0;
	}

//			}
//		}

そのままビルドすると…

1>------ ビルド開始: プロジェクト: T_ZIP_C, 構成: Debug Win32 ------
1>  T_ZIP_C.cpp
1>d:\document\vs\vs\2012\t_clr\t_zip_c\t_zip_c.cpp(6): fatal error C1190: マネージ ターゲット コードには '/clr' が必要です。
========== ビルド: 0 正常終了、1 失敗、0 更新不要、0 スキップ ==========

fatal error C1190: マネージ ターゲット コードには '/clr' が必要です。
プロジェクトの設定で「/clr」に.

1>------ ビルド開始: プロジェクト: T_ZIP_C, 構成: Debug Win32 ------
1>  T_ZIP_C.cpp
1>T_ZIP_C.cpp(7): fatal error C1107: アセンブリ 'System.IO.Compression.FileSystem.dll' がみつかりませんでした: /AI または LIBPATH 環境変数を使用してアセンブリ検索パスを指定してください。
========== ビルド: 0 正常終了、1 失敗、3 更新不要、0 スキップ ==========

「追加の #using ディレクトリ」に dll の場所を指定して通る様にはなったが,これで良いかがわからない.
fatal error C1107: アセンブリ 'System.IO.Compression.FileSystem.dll' がみつかりませんでした:


ほとんど何も入っていない環境で実行すると,

---------------------------
T_ZIP_C.exe - システム エラー
---------------------------
MSVCR110.dll が見つからないため、コードの実行を続行できません。プログラムを再インストールすると、この問題が解決する可能性があります。 
---------------------------
OK   
---------------------------

MSVCR110.dll が見つからないため、コードの実行を続行できません。
VC 2013 や 2015 でビルドしたものも試してみたが,この環境では実行できなかった.
対応するものを入れる必要があるのか?
https://jml.mish.work/index.php/cpp/ref-vcredist-xxx-exe.html


zip_CLI.hxx

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

簡易 Web サーバ C++/CLI

先日の C# のコードから C++/CLI に書き直したものの 更新版
index.html の作成と,ContentType の設定,日本語ファイル名への対応など.

#ifdef		__cplusplus_cli
#using		<System.dll>
#using		<System.Web.dll>
#include	<vcclr.h>
#endif

///////////////////////////////////////////////////////////////////////////
#include	"S_Exec.hxx"
#include	"str_CLI.hxx"
#include	"filestat.hxx"
#include	"filepath.hxx"
#include	"ask_path.hxx"
#include	"itls_tmp.hxx"
#include	"textfile.hxx"
#include	"htmout.hxx"
#include	"stringfn.hxx"

///////////////////////////////////////////////////////////////////////////
struct	MIME_type	{
		LPCTSTR	FExt ;
		LPCTSTR	Type ;
		} ;

//	https://developer.mozilla.org/ja/docs/Web/HTTP/Basics_of_HTTP/MIME_types/Common_types
const	MIME_type	MIME_type_tbl[] =
		{
			_T("htm" ) ,	_T("text/html") ,
			_T("html") ,	_T("text/html") ,
			_T("txt" ) ,	_T("text/plain") ,
			_T("bmp" ) ,	_T("image/bmp") ,
			_T("jpeg") ,	_T("image/jpeg") ,
			_T("jpg" ) ,	_T("image/jpeg") ,
			_T("png" ) ,	_T("image/png") ,
			_T("svg" ) ,	_T("image/svg+xml") ,
			_T("bin" ) ,	_T("application/octet-stream") ,
			_T("pdf" ) ,	_T("application/pdf") ,
			_T("zip" ) ,	_T("application/zip") ,
			_T("   " ) ,	_T("") ,
			_T("\0"  ) ,	_T("") ,
			_T(""    ) ,	_T("") ,
		} ;

inline	tstring	get_MIME_type	(LPCTSTR ext_)
{
	tstring	type = _T("application/octet-stream") ;
	tstring	ext  = ::String_ToLower(ext_) ;
	if (ext.empty())	{
		return	type ;
		}
	const	MIME_type*	mm_ty = MIME_type_tbl ;
	{
		for (size_t index=0 ; index<countof(MIME_type_tbl) ; index++)
		{
			tstring	fext = mm_ty[index].FExt ;
			tstring	ftyp = mm_ty[index].Type ;
			if (fext.length() == 0)          	{	continue ;	}
			if (fext.length() != ext.length())	{	continue ;	}
			if (ext == fext)                	{
				return	mm_ty[index].Type ;
				}
			}
		}
	return	type ;
	}

///////////////////////////////////////////////////////////////////////////
inline	tstring	HT_Make_index_content	(c_tstring& fold)
{
	v_tstring	sub_folds = ::EnumFolders(fold.c_str()) ;
	v_tstring	htm_files = ::EnumFiles  (fold.c_str(),_T("*.htm*")) ;
	tstring		foldName  = ::Path_GetTitle(fold) ;
	tstring	htm_str ;
	{
		Xml_E	htm = HtmOut::html() ;
		{
			Xml_E	head(HTM_head) ;
			{
				head.AddChild(HtmOut::charset_UTF_8()) ;
				head.AddChild(HtmOut::meta_viewport()) ;
				head.AddChild(HtmOut::title(foldName)) ;
				}
			{
				head.AddChild(HtmOut::comment()) ;
				}
			htm.AddChild(head) ;
			}
		{
			Xml_E	body(HTM_body) ;
			{
				{
					body.AddChild(HtmOut::a_parent()) ;
					body.AddChild(HtmOut::hr()) ;
					}
				{
					for (size_t index=0 ; index<sub_folds.size() ; index++) {
						tstring	fold = sub_folds[index] ;
						       	fold = ::Path_DelLastSP(fold) ;
						Xml_E	a_fold = HtmOut::a(::Path_GetName(fold)+_T("/")) ;
						body.AddChild(a_fold) ;
						body.AddChild(HtmOut::br()) ;
						}
					body.AddChild(HtmOut::hr()) ;
					}
				{
					for (size_t index=0 ; index<htm_files.size() ; index++) {
						tstring	html = htm_files[index] ;
						Xml_E	a_html = HtmOut::a(::Path_GetName(html)) ;
						body.AddChild(a_html) ;
						body.AddChild(HtmOut::br()) ;
						}
					}
				}
			htm.AddChild(body) ;
			}
		htm_str = htm.ToText() ;
		}
	return	htm_str ;
	}

tstring		Make_index	(c_tstring& fold)
{
	tstring	result = ::HT_Make_index_content(fold) ;
	return	result ;
	}

///////////////////////////////////////////////////////////////////////////
bool	web_server	(c_tstring& fold,const u_16 port)
{
	tstring	root_ = fold ;
	tstring	port_ = ::To_tstring(port) ;
	tstring	pref_ = _T("http://127.0.0.1:")+port_+_T("/") ;
	System::String^	root	= ::to_gcString(root_) ;
	System::String^	prefix	= ::to_gcString(pref_) ;
	System::Console::WriteLine(prefix) ;
	System::Net::HttpListener^	listener = gcnew System::Net::HttpListener();
	listener->Prefixes->Add(prefix);
	listener->Start();
	while (true) {
		System::Net::HttpListenerContext^	context = listener->GetContext();
		System::Net::HttpListenerRequest^	req = context->Request;
		System::Net::HttpListenerResponse^	res = context->Response;
		System::String^	path = root + req->RawUrl->Replace("/", "\\");
		             	path = System::Web::HttpUtility::UrlDecode(path) ;
		{
			System::Console::WriteLine(req->RawUrl);
			System::Console::WriteLine(path) ;
			}
		if (System::IO::File::Exists(path)) {
			}
		if (System::IO::File::Exists(path)) {
			tstring	ext = ::Path_GetExtLow(::to_tstring(path)) ;
			array<System::Byte>^	content = System::IO::File::ReadAllBytes(path);
			res->ContentType = ::to_gcString(::get_MIME_type(ext.c_str())) ;
			res->OutputStream->Write(content, 0, content->Length);
			}
		else {
			tstring               	cnt_index = ::Make_index (::to_tstring(path)) ;
			array<System::Byte>^	content ;
			{
				static	long	i_count = 0 ;
				            	i_count++ ;
				tstring	tmp_path = ::Get_i_Tools_tmp_date() ;
				tstring	htm_name = ::To_tstring(port) + _T("_") + ::u32to0t(i_count,10,4) + _T(".htm") ;
				tstring	out_path = ::Path_AddLastSP(tmp_path) + htm_name ;
				::SaveUTF8(out_path.c_str(),cnt_index) ;
				content = System::IO::File::ReadAllBytes(::to_gcString(out_path.c_str())) ;
				}
			res->ContentType = ::to_gcString(::get_MIME_type(_T("htm"))) ;
			res->OutputStream->Write(content, 0, content->Length);
			}
		res->Close();
		}
	return	true ;
	}

///////////////////////////////////////////////////////////////////////////
bool	test	(c_tstring& str)
{
	tstring	fold = str ;
	{
		if (::File_IsDirectory(fold))	{	;                          	}
		else                        	{	fold = ::Path_GetDir(fold) ;	}
		}
	std::terr << fold << std::endl ;
	{
		u_16	tick = u_16(::GetTickCount()) ;
		u_16	port = u_16(50000 + (tick&0x1fff)) ;
		{
			tstring	port_ = ::To_tstring(port) ;
			tstring	pref_ = _T("http://127.0.0.1:")+port_+_T("/") ;
			S_Exec	se ;
			se.SetFile(pref_.c_str()) ;
			se.Execute() ;
			}
		::web_server(fold,port) ;
		}
	return	true ;
	}

///////////////////////////////////////////////////////////////////////////
int	_tmain	(int argc,_TCHAR* argv[])
{
	tstring	path ;
	{
		#ifdef	OFN_filter_All
			path = ::ask_path(false) ;
		//	path = ::ask_path(true) ;
		#else
			path = ::ask_cli(_T("folder ... ? =")) ;
		#endif
		}
	if (!path.empty()) {
		::test(path) ;
		}
	return 0;
	}

///////////////////////////////////////////////////////////////////////////
#include	"messbar.cxx"

* 幾つかのコードが揃っていないため,そのままではビルドできません.
簡易 Web サーバ   C++/CLI
https://jml.mish.work/index.php/i-tools/web-svr.html

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

C# のコードを C++/CLI に

先日の「簡易 Web サーバ C#」のコードを C++ で.

///////////////////////////////////////////////////////////////////////////////////
//	C# -> C++/CLI
///////////////////////////////////////////////////////////////////////////////////

#include <stdio.h>
#include <tchar.h>

//using	System;
//using	System.IO;
//using	System.Net;

#using  <System.dll>

bool	test	(void)
{
//
//	class SimpleWebServer
//	{
//		static void Main()
//		{
//			string		root = @"c:\wwwroot\";	// ドキュメント・ルート
//					root = @".\";
			System::String^	root = "./" ;
//			string		prefix = "http://*/";	// 受け付けるURL
//					prefix = "http://127.0.0.1:65432/" ;
			System::String^	prefix = "http://127.0.0.1:55555/" ;
//	
//			HttpListener 			listener = new HttpListener();
			System::Net::HttpListener^	listener = gcnew System::Net::HttpListener();
//			listener. Prefixes. Add(prefix);	// プレフィックスの登録
			listener->Prefixes->Add(prefix);
//			listener. Start();
			listener->Start();
//	
//			while (true) {
			while (true) {
//				HttpListenerContext			context = listener. GetContext();
				System::Net::HttpListenerContext^	context = listener->GetContext();
//				HttpListenerRequest			req = context. Request;
				System::Net::HttpListenerRequest^	req = context->Request;
//				HttpListenerResponse			res = context. Response;
				System::Net::HttpListenerResponse^	res = context->Response;
//	
//				Console.	 WriteLine(req. RawUrl);
				System::Console::WriteLine(req->RawUrl);
//	
//				// リクエストされたURLからファイルのパスを求める
//				string		path = root + req. RawUrl. Replace("/", "\\");
				System::String^	path = root + req->RawUrl->Replace("/", "\\");
//	
//				// ファイルが存在すればレスポンス・ストリームに書き出す
//				if (            File. Exists(path)) {
				if (System::IO::File::Exists(path)) {
//					byte[]			content =             File. ReadAllBytes(path);
					array<System::Byte>^	content = System::IO::File::ReadAllBytes(path);
//					res. OutputStream. Write(content, 0, content. Length);
					res->OutputStream->Write(content, 0, content->Length);
//					}
					}
//				res. Close();
				res->Close();
//				}
				}
//			}
//		}
//
	return	true ;
	}

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

Web サーバ   C++/CLI

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

VC 8 で C++/CLI

VC 10 ではある程度確認が取れたので,今度は VC 8 で.
先ず,コンソール AP .ビルドすると,

1>------ ビルド開始: プロジェクト: T_Con_1, 構成: Debug Win32 ------
1>コンパイルしています...
1>T_Con_1.cpp
1>EnumFile.hxx MessageBar  No Support
1>C:\Program Files (x86)\Microsoft Visual Studio 8\VC\include\vcclr.h(43) : error C2446: '!=' : 'int' 型から 'cli::interior_ptr<Type>' 型への変換ができません。
1>        with
1>        [
1>            Type=unsigned char
1>        ]
1>T:\Develop\_.SRC\_CLI\str_CLI.hxx(41) : error C2446: '==' : 'int' 型から 'System::String ^' 型への変換ができません。
1>        使用可能なユーザー定義された変換演算子がない、または
1>        演算型のボックス化された形式からターゲット型への標準変換は存在しません
1>T:\Develop\_.SRC\_CLI\str_CLI.hxx(61) : warning C4267: '初期化中' : 'size_t' から 'int' に変換しました。データが失われているかもしれません。
1>T:\Develop\_.SRC\_CLI\str_CLI.hxx(64) : warning C4267: '初期化中' : 'size_t' から 'int' に変換しました。データが失われているかもしれません。
1>T_Con_1 - エラー 2、警告 2
========== ビルド: 0 正常終了、1 失敗、0 更新、0 スキップ ==========

vcclr.h 内のエラーは,次の様に cpp の最初で vcclr.h を読み込むことで回避できる.

#ifdef      __cplusplus_cli
#include    <vcclr.h>
#endif

もう一つのエラーは次の所で,str が nullptr でないかを比較している所.

tstring	to_tstring	(System::String^ str)	
{
	if (str == nullptr)		{	return	_T("") ;	}
	pin_ptr	<const wchar_t>	pStr = PtrToStringChars(str) ;
	tstring	tstr = pStr ;
	return	tstr ;
	}

検索すると System::String::Empty を使えば良さそうたが,str が 0 との比較は必要ないのか?
VC 8 で  C++/CLI

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

MFC AP で .NET の利用

MFC ダイアログ AP を C++/CLI に.
VC 2010 で,MFC ダイアログベースのスケルトンを作成.
リストボックスを追加して,コントロールの変数を割り当て.
プロジェクトの「プロパティ」で「共通言語ランタイム サポート(/clr)」に変更.
ダイアログのソースに次のものを追加.

#include	"enumfile.hxx"
#include	"vtst_MFC.hxx"
#include	"str_CLI.hxx"

#using		<System.dll>
#using		<mscorlib.dll>

OnInitDialog に次のコードを追加.

	{
		v_tstring	files = ::EnumFiles(_T("./"),_T("*.*")) ;
		::ToListBox(files,&m_CtrlListFiles) ;
		}
	{
		array<System::String^>^ gfile = System::IO::Directory::GetFiles(_T("./"));
		v_tstring	files ;
		for (int i = 0; i<gfile->Length; i++) {
			tstring	file = ::to_tstring(gfile[i]) ;
			files.push_back(file) ;
			}
		::ToListBox(files,&m_CtrlListFiles) ;
		}

MFC AP に「共通言語ランタイム サポート(/clr)」追加


「共通言語ランタイム サポート(/clr)」とすることで良いならば,コンソール AP ではどうなのか?
空のコンソール AP を作成して,次の様なコード.

#include	"enumfile.hxx"
#include	"str_CLI.hxx"

#using  	<System.dll>

bool	test	(c_tstring& str)
{
	tstring	fold_ = str ;
	{
		if (::File_IsDirectory(fold_))	{	;				}
		else				{	fold_ = ::Path_GetDir(fold_) ;	}
		}
	std::terr << fold_ << std::endl ;
	{
		v_tstring	files = ::EnumFiles(fold_,_T("*.*")) ;
		for (size_t index=0 ; index<files.size() ; index++) {
			std::terr << files[index] << std::endl ;
			}
		}
	{
		System::String^	fold = ::to_gcString(fold_) ;
		array<System::String^>^ gfile = System::IO::Directory::GetFiles(fold);
		for (int i = 0; i<gfile->Length; i++) {
			System::String^	file = gfile[i] ;
			System::Console::WriteLine(file) ;
			}
		}
	return	true ;
	}

int _tmain(int argc, _TCHAR* argv[])
{
	::test(_T("./")) ;
	return 0;
	}

Win32 コンソール AP C++  /clr に
::GetOpenFileName使用 した 方法 も可能だったが…
C++/CLI コンソール AP で GetOpenFileName を使用
::SHBrowseForFolder では,止まってしまう?


プロジェクトの作成で「CLR コンソール アプリケーション」として,main 関数を次の様にしたもの.

int main(array<System::String ^> ^args)
{
	{
	//	::call_func(argc,argv) ;
		::call_func() ;
		}
	{
		::test(_T("Test")) ;
		}
	::ask_wait() ;
	return 0;
	}

これは,ビルドするとよくわからないエラー.

1>------ ビルド開始: プロジェクト: T_CLR_2, 構成: Debug Win32 ------
1>  T_CLR_2.cpp
1>  EnumFile.hxx MessageBar  No Support
1>  .NETFramework,Version=v4.0.AssemblyAttributes.cpp
1>T_CLR_2.obj : error LNK2028: 未解決のトークン (0A000665) "extern "C" unsigned long __stdcall CommDlgExtendedError(void)" (?CommDlgExtendedError@@$$J10YGKXZ) が関数 "class std::basic_string<wchar_t,struct std::char_traits<wchar_t>,class std::allocator<wchar_t> > __cdecl FD_GetOpenFile(struct HWND__ *,wchar_t const *,wchar_t const *,wchar_t const *)" (?FD_GetOpenFile@@$$FYA?AV?$basic_string@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@PAUHWND__@@PB_W11@Z) で参照されました。
1>T_CLR_2.obj : error LNK2028: 未解決のトークン (0A000695) "extern "C" int __stdcall SHGetPathFromIDListW(struct _ITEMIDLIST const *,wchar_t *)" (?SHGetPathFromIDListW@@$$J18YGHPBU_ITEMIDLIST@@PA_W@Z) が関数 "class std::basic_string<wchar_t,struct std::char_traits<wchar_t>,class std::allocator<wchar_t> > __cdecl SH_GetPathFromIDList(struct _ITEMIDLIST const *)" (?SH_GetPathFromIDList@@$$FYA?AV?$basic_string@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@PBU_ITEMIDLIST@@@Z) で参照されました。
1>T_CLR_2.obj : error LNK2028: 未解決のトークン (0A00069F) "extern "C" void __stdcall CoTaskMemFree(void *)" (?CoTaskMemFree@@$$J14YGXPAX@Z) が関数 "class std::basic_string<wchar_t,struct std::char_traits<wchar_t>,class std::allocator<wchar_t> > __cdecl Browse_Folder(struct HWND__ *,wchar_t const *,wchar_t const *)" (?Browse_Folder@@$$FYA?AV?$basic_string@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@PAUHWND__@@PB_W1@Z) で参照されました。
1>T_CLR_2.obj : error LNK2028: 未解決のトークン (0A0006B0) "extern "C" struct HWND__ * __stdcall FindWindowW(wchar_t const *,wchar_t const *)" (?FindWindowW@@$$J18YGPAUHWND__@@PB_W0@Z) が関数 "struct HWND__ * __cdecl GetConsoleHwnd(void)" (?GetConsoleHwnd@@$$FYAPAUHWND__@@XZ) で参照されました。
1>T_CLR_2.obj : error LNK2028: 未解決のトークン (0A00070A) "extern "C" struct _ITEMIDLIST * __stdcall SHBrowseForFolderW(struct _browseinfoW *)" (?SHBrowseForFolderW@@$$J14YGPAU_ITEMIDLIST@@PAU_browseinfoW@@@Z) が関数 "class std::basic_string<wchar_t,struct std::char_traits<wchar_t>,class std::allocator<wchar_t> > __cdecl Browse_Folder(struct HWND__ *,wchar_t const *,wchar_t const *)" (?Browse_Folder@@$$FYA?AV?$basic_string@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@PAUHWND__@@PB_W1@Z) で参照されました。
1>T_CLR_2.obj : error LNK2028: 未解決のトークン (0A000710) "extern "C" int __stdcall GetOpenFileNameW(struct tagOFNW *)" (?GetOpenFileNameW@@$$J14YGHPAUtagOFNW@@@Z) が関数 "class std::basic_string<wchar_t,struct std::char_traits<wchar_t>,class std::allocator<wchar_t> > __cdecl FD_GetOpenFile(struct HWND__ *,wchar_t const *,wchar_t const *,wchar_t const *)" (?FD_GetOpenFile@@$$FYA?AV?$basic_string@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@PAUHWND__@@PB_W11@Z) で参照されました。
1>T_CLR_2.obj : error LNK2028: 未解決のトークン (0A000741) "extern "C" long __stdcall SendMessageW(struct HWND__ *,unsigned int,unsigned int,long)" (?SendMessageW@@$$J216YGJPAUHWND__@@IIJ@Z) が関数 "extern "C" long __cdecl SendMessage(struct HWND__ *,unsigned int,unsigned int,long)" (?SendMessage@@$$J0YAJPAUHWND__@@IIJ@Z) で参照されました。
1>T_CLR_2.obj : error LNK2019: 未解決の外部シンボル "extern "C" long __stdcall SendMessageW(struct HWND__ *,unsigned int,unsigned int,long)" (?SendMessageW@@$$J216YGJPAUHWND__@@IIJ@Z) が関数 "extern "C" long __cdecl SendMessage(struct HWND__ *,unsigned int,unsigned int,long)" (?SendMessage@@$$J0YAJPAUHWND__@@IIJ@Z) で参照されました。
1>T_CLR_2.obj : error LNK2019: 未解決の外部シンボル "extern "C" int __stdcall SHGetPathFromIDListW(struct _ITEMIDLIST const *,wchar_t *)" (?SHGetPathFromIDListW@@$$J18YGHPBU_ITEMIDLIST@@PA_W@Z) が関数 "class std::basic_string<wchar_t,struct std::char_traits<wchar_t>,class std::allocator<wchar_t> > __cdecl SH_GetPathFromIDList(struct _ITEMIDLIST const *)" (?SH_GetPathFromIDList@@$$FYA?AV?$basic_string@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@PBU_ITEMIDLIST@@@Z) で参照されました。
1>T_CLR_2.obj : error LNK2019: 未解決の外部シンボル "extern "C" void __stdcall CoTaskMemFree(void *)" (?CoTaskMemFree@@$$J14YGXPAX@Z) が関数 "class std::basic_string<wchar_t,struct std::char_traits<wchar_t>,class std::allocator<wchar_t> > __cdecl Browse_Folder(struct HWND__ *,wchar_t const *,wchar_t const *)" (?Browse_Folder@@$$FYA?AV?$basic_string@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@PAUHWND__@@PB_W1@Z) で参照されました。
1>T_CLR_2.obj : error LNK2019: 未解決の外部シンボル "extern "C" struct _ITEMIDLIST * __stdcall SHBrowseForFolderW(struct _browseinfoW *)" (?SHBrowseForFolderW@@$$J14YGPAU_ITEMIDLIST@@PAU_browseinfoW@@@Z) が関数 "class std::basic_string<wchar_t,struct std::char_traits<wchar_t>,class std::allocator<wchar_t> > __cdecl Browse_Folder(struct HWND__ *,wchar_t const *,wchar_t const *)" (?Browse_Folder@@$$FYA?AV?$basic_string@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@PAUHWND__@@PB_W1@Z) で参照されました。
1>T_CLR_2.obj : error LNK2019: 未解決の外部シンボル "extern "C" unsigned long __stdcall CommDlgExtendedError(void)" (?CommDlgExtendedError@@$$J10YGKXZ) が関数 "class std::basic_string<wchar_t,struct std::char_traits<wchar_t>,class std::allocator<wchar_t> > __cdecl FD_GetOpenFile(struct HWND__ *,wchar_t const *,wchar_t const *,wchar_t const *)" (?FD_GetOpenFile@@$$FYA?AV?$basic_string@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@PAUHWND__@@PB_W11@Z) で参照されました。
1>T_CLR_2.obj : error LNK2019: 未解決の外部シンボル "extern "C" int __stdcall GetOpenFileNameW(struct tagOFNW *)" (?GetOpenFileNameW@@$$J14YGHPAUtagOFNW@@@Z) が関数 "class std::basic_string<wchar_t,struct std::char_traits<wchar_t>,class std::allocator<wchar_t> > __cdecl FD_GetOpenFile(struct HWND__ *,wchar_t const *,wchar_t const *,wchar_t const *)" (?FD_GetOpenFile@@$$FYA?AV?$basic_string@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@PAUHWND__@@PB_W11@Z) で参照されました。
1>T_CLR_2.obj : error LNK2019: 未解決の外部シンボル "extern "C" struct HWND__ * __stdcall FindWindowW(wchar_t const *,wchar_t const *)" (?FindWindowW@@$$J18YGPAUHWND__@@PB_W0@Z) が関数 "struct HWND__ * __cdecl GetConsoleHwnd(void)" (?GetConsoleHwnd@@$$FYAPAUHWND__@@XZ) で参照されました。
1>D:\Document\VS\VS\2010\T_CLI\Debug\T_CLR_2.exe : fatal error LNK1120: 外部参照 14 が未解決です。
========== ビルド: 0 正常終了、1 失敗、4 更新不要、0 スキップ ==========

どこかを設定を設定すれば良いのかもしれないが,ちょっとわからない.

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

「.NET なんとか」

「.NET なんとか」のメモ.
.NET Framework
.NET (.NET Core)
.NET MAUI
.NET CLI


VS などが入っている環境だと,次のコマンドで SDK バージョンを確認できる.
dotnet –list-sdks
dotnet --info


Visual C++ で基本的なファイル I/O を実行する
C++/CLI プロジェクトを .NET Core または .NET 5 に移植する方法


C++/CLI
C++/CX
C++/WinRT


C++/CLI
「プロジェクト テンプレート」で「CLR 空のプロジェクト(.NET Framework)」を選択.
CLR .NET Framework
次の様な内容のソースを追加.

//#include "pch.h"

using namespace System;

int main(array<System::String^>^ args)
{
    Console::Write("test");
    return 0;
    }

VC 2022  CLR  プロパティ


次の所のコードと std::cin との混在.
ファイル処理と I/O (C++/CLI)

// file_info.cpp
// compile with: /clr

using namespace System;
using namespace System::IO;

#include	"ask_cli.hxx"

#include	"str_CLI.hxx"

bool	Draw_FileInfo	(c_tstring& file_name)
{
	String^		file = ::to_gcString(file_name) ;

	FileInfo^ fi = gcnew FileInfo(file) ;

	Console::WriteLine("file size: {0}", fi->Length);

	Console::Write    ("File creation date:  ");
	Console::Write    (        fi->CreationTime.Month.ToString());
	Console::Write    (".{0}", fi->CreationTime.Day.ToString());
	Console::WriteLine(".{0}", fi->CreationTime.Year.ToString());

	Console::Write    ("Last access date:  ");
	Console::Write    (        fi->LastAccessTime.Month.ToString());
	Console::Write    (".{0}", fi->LastAccessTime.Day.ToString());
	Console::WriteLine(".{0}", fi->LastAccessTime.Year.ToString());

	return	true ;
	}

int main()
{
	array<String^>^ args = Environment::GetCommandLineArgs();
	if (args->Length > 1) {
		tstring	file_name = ::to_tstring(args[1]) ;
		::Draw_FileInfo(file_name) ;
		}
	else {
		while(true)	{
			tstring	path = ::ask_cli(_T("file ... ? =")) ;
			if (path.empty())	{	break ;		}
			::Draw_FileInfo(path) ;
			}
		}
	return 0;
	}
Is this 投稿 useful? Useful Useless 0 of 0 people say this 投稿 is useful.

簡易 Web サーバ C#

System.Net.HttpListener.dll で比較的簡単にできるみたいなので,ちょっと調べてみた.


最初に見つけたのは次の所.
.NET TIPS 簡易Webサーバを実装するには?[2.0のみ、C#、VB]
Win10 C:\Windows\Microsoft.NET\Framework\v3.5\csc.exe でコンパイルして問題なく動作する.
そのままのコードでは,管理者として起動しなければならないのと,ルートが固定のため少し変更.

	string	root = @"c:\wwwroot\";	// ドキュメント・ルート
		root = @".\";
	string	prefix = "http://*/";	// 受け付けるURL
		prefix = "http://localhost:65432/" ;

これで exe を対象のルートにコピーして,起動させることができる.
HttpListener  C#


localhost ではなく 127.0.0.1 を指定すると //localhost:65432/… としてもアクセス可能.
prefix = "http://127.0.0.1:65432/" ;


参考にさせてもらった所.
https://yryr.me/programming/local-http-server.html
https://www.3ace-net.co.jp/blog/201304151845.html
https://d01tsumath.hatenablog.com/entry/2019/08/16/190000


これらをテストしていて,WebGL のページを表示すると,極端に遅くなる.
以前は FHD 環境だったが,先日から 4K でいろいろと…
そのため WebGL などのページを表示すると,GPU のメモリを大量に使用するみたい.
タスクマネージャの「専用 GPU メモリ」は 10 GB 程度になっているが,どこを使用しているの?
設定にもよるかもしれないが Firefox で次の所を表示すると「専用 GPU メモリ」の使用量が増えていく.
https://threejs.org/examples/#webgl_instancing_performance


C# のコードを C++/CLI に
簡易 Web サーバ C++/CLI
https://jml.mish.work/index.php/i-tools/web-svr.html

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

簡易 Web サーバ

次の様なものをブラウザで表示するために…
http://mish.html.xdomain.jp/Test/WebGL/Sphere.html


「Web Server for Chrome」は以前書いた.
http://test_wp.mish.work/2022/01/chrome-web.html
Win11 環境で同様に実行すると,次の様な表示が…
「Web Server for Chrome」は現在サポートされていません


開発環境には VS 2022 などが入っているので Python を使用した方法
…\Test\Web\WebGL\ に html などをコピー.
コマンドプロンプトで …\Test に移動.
py -m http.server
これで 127.0.0.1:8000 でアクセスできる.
終了は「Ctrl」+「C」.
py -m http.server


ASUSTOR NAS だと,
python -m http.server
python -m http.server
QNAP NAS や Synology NAS でも同様.Raspberry Pi にもあった.


検索すると System.Net.HttpListener.dll と言うのが見つかる.
それを使っていると思われる次の所からコードを拝借.
Windows 標準で Web サーバを起動する
System.Net.HttpListener.dll
勉強を兼ねて,ちょっとやってみるか.


2023/01/17
https://jml.mish.work/index.php/i-tools/web-svr.html
C++/CLI で作成した 簡易 Web サーバ

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

C# のコードを C++.NET で…

MSDN にあるサンプルを VC++2008 でビルドする.
MSDN 四角形内にテキストを折り返して描画する


新規プロジェクトで「Windows フォーム アプリケーション」.
「新規プロジェクト」-「Windows フォーム アプリケーション」
Paint のハンドラを追加.
Paint ハンドラの追加


private: System::Void Form1_Paint(System::Object^  sender, System::Windows::Forms::PaintEventArgs^  e) {
/*
  string text2 = “Draw text in a rectangle by passing a RectF to the DrawString method.”;
  using (Font font2 = new Font(“Arial”, 12, FontStyle.Bold, GraphicsUnit.Point))
  {
    Rectangle rect2 = new Rectangle(30, 10, 100, 122);
    // Specify the text is wrapped.
    TextFormatFlags flags = TextFormatFlags.WordBreak;
    TextRenderer.DrawText(e.Graphics, text2, font2, rect2, Color.Blue, flags);
    e.Graphics.DrawRectangle(Pens.Black, Rectangle.Round(rect2));
  }
*/

  String^        text2 = “Draw text in a rectangle by passing a RectF to the DrawString method.”;
  Drawing::Font^     font2 = gcnew    Drawing::Font(“Arial”, 12, FontStyle::Bold, GraphicsUnit::Point) ;
  Drawing::Rectangle^    rect2 = gcnew    Drawing::Rectangle(30,10,100,122) ;
  TextFormatFlags        flags = TextFormatFlags::WordBreak ;
  TextRenderer::DrawText(e->Graphics,text2,font2,*rect2,Color::Blue,flags) ;
  e->Graphics->DrawRectangle(Pens::Black,*rect2) ;
}


RECT または CRect にあたるものは,Drawing::Rectangle .
ここで利用している Font は Drawing::Font としないとエラーになる.
  c:\…\drawt_2\Form1.h(87) : error C2061: 構文エラー : 識別子 ‘Font’
DrawText などの Rectangle はハンドルではなく実体.


2013/11/05
C# の文字列の前の ‘@’
リテラル文字列


MFC での文字列の変数に対する += .
  CString str ;
  str += _T(“123”) ;
C++/CLI で System::String は可能であるが,C# の string ではエラーとなるみたい.


2013/11/06
C# で g.Dispose() ;
  C++ では delete g ;
Graphics.Dispose メソッド

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

tlbimp

今度は「COM 相互運用機能」ってやつ.
Tlbimp.exe を利用して,AsFile.tlb を ISFile.dll として出力.
  SDK コマンドプロンプトを開き,~\ReleaseU のフォルダに移動.
  tlbimp AsFile.tlb ISFile.dll
C# フォームアプリケーションを作成して,ボタンを配置.
  参照の追加で,iSFile.dll を追加.
    using iSFile; を追加.
    private void button1_Click(object sender,EventArgs e) {
      iSFile.SearchF srchF = new iSFile.SearchF() ;
      string selFile = srchF.BrowseFile(“%Temp%\\”,””) ;
      MessageBox.Show(selFile) ;
      }
同様の動作の vbs での呼び出しは,
  dim oFSch : set oFSch = CreateObject(“AsFile.SearchF”)
  selFile = oFSch.BrowseFile(“%Temp%\”,””) ;
  MsgBox x
以前聞いた時には,もっと面倒なイメージがあったがそれ程でもない.
  ただ COM の部分が確定していない(平行してコードを書いている)時は面倒なのかも.


同様に AsHVR.exe をやってみたら,実行時エラー.
型 ‘AsHVR.AsHVRClass’ の COM オブジェクトをインターフェイス型 ‘AsHVR.IAsHVR’ にキャストできません。
IID ‘{1625D8E7-B67B-4592-878F-ECFAD1227734}’ が指定されたインターフェイスの COM コンポーネント上での QueryInterface 呼び出しのときに次のエラーが発生したため、この操作に失敗しました:
インターフェイスがサポートされていません (HRESULT からの例外: 0x80004002 (E_NOINTERFACE))。
0x80004002 (E_NOINTERFACE)
これが面倒だったのかも?


他にも,T54W7U64 環境で,DevXP\~\CSCallL\bin\Debug\CSCallL.exe を起動して,「ボタン 1」 もエラーとなる.
  これは,AsFile.dll の 64 ビット版がないことによるものと思うが,…
  うまい方法がよくわからない.


2013/08/06
既存の AsHVR.exe などがうまく動作しないのは変わらないが,
  VC 8 で新規に MFC ダイアログベースのプロジェクト TstComE を作成.オートメーションを有効に.
  メソッド GetTmpPath を追加して実行するとうまくいった.


C++/CLI コンソール AP として作成.
// CPCallL.cpp : メイン プロジェクト ファイルです。
#include "stdafx.h"
using namespace System;
using namespace System::Windows::Forms;
int main(array<System::String ^> ^args)
{
  {
    iSFile::SearchF^ srchF = gcnew iSFile::SearchF();
  // String^ selFile = srchF->BrowseFile("%Temp%\\","") ;
  // MessageBox::Show(selFile) ;
    }
  {
    AsHVR::AsHVR^ hmpvr = gcnew AsHVR::AsHVR();
  // String^ key = hmpvr->GetKeySP();
  // MessageBox::Show(key);
    }
  {
    TstComE::TstComE^ tce = gcnew TstComE::TstComE() ;
    String^ tmpFile = tce->GetTmpPath() ;
    MessageBox::Show(tmpFile) ;
    }
  return 0;
  }
今度は TstComE 以外うまく動作しない.

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

CLI MSDN のサンプルなど

連載! とことん VC++
  第 8 回 C++/CLI を利用した相互運用 ~ネイティブ C++ から .NET の利用~
  第 9 回 C++/CLI を利用した相互運用 ~.NET からのネイティブ C++ 資産の再利用~


VC++ 2010 Express などが対象となっている.
インストールなしで用意できた環境が VS 2008 だったが,特に問題なく進められた.


メニューの「プロジェクト」-「参照の追加」は,VC 2003 以降?
VC 2005 , VC 2008 では,ソリューションエクスプローラのプロジェクトの下に「参照設定」がない?
  VC 2003 には存在するので.
VC 2002 では,プログラミング VisualC++.NET Vol.2 429 ページで
  #using <..\Ex32a\Debug\Ex32a.dll> となっている.


さまざまな文字列型間で変換する
Visual C++ で System::String* から char* に変換する方法
System::String を wchar_t* または char* に変換する
BUG: The VC++ .NET or VC++ 2005 debugger cannot display std::string and std::wstring variables correctly


2013/08/05
C++/CLI を用いて、.NET 対応アプリケーションから MFC 対応クラスを使用する
  慣れかもしれないが,ちょっと面倒に感じる.

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

OpenCV 環境作成

C++/CLI & OpenCV 画像処理 GUI プログラミング を購入したので,環境を作ってみた.
OpenCV 2.4.3 などは VC 9 , 10 が標準で用意されているので,VS 2008 をインストール.
  VS のインストールに時間がかかるので,平行して Linux の環境にも作成してみたが,よくわからず.
第 1 章の C++/CLI での読込まで,特に問題なくできた.


第 2 章をやっていて,ビルドすると
  —— ビルド開始: プロジェクト: 03Flip, 構成: Debug Win32 ——
  コンパイルしています…
  stdafx.cpp
  コンパイルしています…
  AssemblyInfo.cpp
  03Flip.cpp
  C:\…\include\opencv2/core/types_c.h(305) : error C3862:
     ‘cvRound’: /clr:pure または /clr:safe を伴うアンマネージ関数をコンパイルできません
     インラインのネイティブ アセンブリはマネージ コードでサポートされていません
  C:\…\include\opencv2/core/types_c.h(305) : error C3645:
     ‘cvRound’ : __clrcall は、ネイティブ コードにコンパイルされた関数では使用できません
  コードを生成中…
  ビルドログは “file://c:\…\Projects\T_OpenCV3Flip\Debug\BuildLog.htm” に保存されました。
  03Flip – エラー 2、警告 0
/clr:pure から /clr に変更していなかった.


2013/07/18
第 5 章で,toolStripStatusLabel1 がわからなかった.
  statusStrip1 を配置後,ステータスバー上のドロップダウンで,StatusLabel を追加する必要がある.
第 7 章のドラッグ&ドロップ対応で,
  どこを間違えているのかわからないが,ボタンの Panel 部分にかぶって PictureBox が表示されている.
  保存対応ではもう一度最初からやって,これは OK.
これらとは直接関係ないが,変な現象.サムネイルが合っていない.再起動しても改善せず.
OpenCV


2013/07/19
7 章のPictureBox がかぶるのは,どうも他のフォームからコピーした時に何かの情報が変わってしまうみたい.
Panel を削除して,もう一度 Panel と PictureBox を配置することにより意図した動作となった.

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

フォームへの描画

フォームに,左上から右下へグラデーションで表示する動作を幾つかの言語で書いてみた.


C#
//…
using System.Drawing.Drawing2D;
//…
namespace WinApCS
{
   public partial class FormCS : Form
   {
     public FormCS()
     {
       InitializeComponent();
     }
     private void Form1_Paint(object sender, PaintEventArgs e)
     {
       LinearGradientBrush brush = new LinearGradientBrush
            (ClientRectangle,Color.Green,Color.White,LinearGradientMode.ForwardDiagonal);
       e.Graphics.FillRectangle(brush,ClientRectangle);
     }
     protected override void OnResize(System.EventArgs e)
     {
       Invalidate();
     }
   }
}


VB
Imports System.Drawing.Drawing2D
Public Class FormVB
   Protected Overrides Sub OnPaint(ByVal e As System.Windows.Forms.PaintEventArgs)
     Dim brush As New LinearGradientBrush
            (ClientRectangle, Color.Blue, Color.White, LinearGradientMode.ForwardDiagonal)
     e.Graphics.FillRectangle(brush, ClientRectangle)
   End Sub
   Protected Overrides Sub OnResize(ByVal e As System.EventArgs)
     Invalidate()
   End Sub
End Class


J#
//…
import System.Drawing.Drawing2D.*;
//…
public class FormJS extends System.Windows.Forms.Form
{
   //…
   private void Form1_Paint(Object sender, PaintEventArgs e)
   {
     LinearGradientBrush brush = new LinearGradientBrush
         (get_ClientRectangle(),Color.get_Red(),Color.get_White(),LinearGradientMode.ForwardDiagonal) ;
     e.get_Graphics().FillRectangle(brush,get_ClientRectangle()) ;
   }
   protected void OnResize(System.EventArgs e)
   {
     this.Invalidate();
   }
}


C++/CLI
//…
namespace WFmCpClr {
   //…
   using namespace System::Drawing::Drawing2D;
   //…
   public ref class FormVC : public System::Windows::Forms::Form
   {
     //…
     private: System::Void FormVC_Paint
            (System::Object^ sender, System::Windows::Forms::PaintEventArgs^ e) {
       LinearGradientBrush^ brush = gcnew LinearGradientBrush
            (ClientRectangle,Color::Olive,Color::White,LinearGradientMode::ForwardDiagonal) ;
       e->Graphics->FillRectangle(brush,ClientRectangle) ;
     }
     private: System::Void FormVC_Resize(System::Object^ sender, System::EventArgs^ e) {
       Invalidate();
     }
   };
}

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

CLI

今度は,C++/CLI .
以前作成した MFC プロジェクト MemStt を変更.
  Release 版プロジェクトのプロパティで,
    「構成プロパティ」-「全般」-「共通言語ランタイム…」を「/clr」に.
      ビルドすると確かにファイルサイズは大きくなる.
  Debug 版だと,
    cl : コマンド ライン error D8016 : コマンド ライン オプション ‘/RTC1’ と ‘/clr’ は同時に指定できません
      正しい対応方法はわからないが,vcproj をエディタで開いて,BasicRuntimeChecks=”3″ を削除.


Form クラスに MemoryStatusAry を確保すると,
  c:\~\Form1.h(26) : error C4368: ‘MemSA’ をマネージ ‘MemSF::Form’ のメンバとして定義できません。
    MemoryStatusAry* MemSA とすることで対応?

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

MFC 14 以降の CCheckListBox で…

何年か前,幾つかのプロジェクトを VC 14 に対応しようとして CCheckListBox の表示がうまくなかった.
CCheckListBox  VC 2015 スタティックリンク
CCheckListBox を使っているプロジェクトは限られているので,~MFC 12 にしていた.


今回 いろいろとあり VC 2017 ~ 2022 に対応することに.
MFC が更新されているのかわからないが,以前のものより少し動作は良くなっている?
相変わらず,表示直後にずれているのと,高さが MFC 12 以前に比べ詰まっている.
CCheckListBox VC 2015 でビルドし直したもの


MFC CCheckListBox ずれる」で検索すると,OnInitDialog() などで 高さを指定 すれば良いとあった.

{
	CRect	rect ;
	m_CtrlSExtDllNow.GetWindowRect(&rect) ;		//	他のコントロールの高さを利用
	m_CtrlListSExt.SetItemHeight(0,rect.Height()) ;
	}

面倒だったのでエディットボックスの高さを利用している.
これで MFC 12 などで作成したものと同じ様な表示になった.
CCheckListBox  SetItemHeight を追加

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

クリップボード ビューア

以前まとめたもの.
ClipView.doc


MSDNのドキュメントは,”Creating a Clipboard Viewer Window” で見つかる.
https://msdn.microsoft.com/en-us/library/windows/desktop/ms649016.aspx
mk:@MSITStore:j:\MSDN\ipc.chm::/hh/winbase/clipbrd_47ok.htm

WM_CREATE ビューアとしての登録
NextWnd = ::SetClipboardViewer(hWnd) ;

WM_DESTORY ビューアの登録解除
::ChangeClipboardChain(hWnd,NextWnd) ;

WM_CHANGECBCHAIN 他のビューアが登録解除された
if ((HWND)wParam == NextWnd) { NextWnd = (HWND)lParam ; }
else if (NextWnd != NULL) { ::SendMessage(NextWnd,uMsg,wParam,lParam) ; }

WM_DRAWCLIPBOARD クリップボードの内容が更新された
// 描画または相当の動作
if (NextWnd != NULL) { ::SendMessage(NextWnd,uMsg,wParam,lParam) ; }


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

「お名前.com」の設定

先日申し込んだ「お名前.com」の設定のメモ.

やはり全体的にわかり辛い.
ログインした時のホップアップも邪魔.
欲しい情報の検索をかけても help.onamae.com が上位に表示されてしまう.
またその内容(特に画像)が古いものが多い気がする.


メールが多すぎるので「お知らせメールの受信」を「配信なし」に設定.
画面右上の「お名前ID:?????」の所をクリックして「会員情報の確認/変更」に入り,その画面の下の方で設定.
whois 情報は申込時のデフォルト(WHOIS情報公開代行)のまま.


DNS の設定へ入る方法がわかり辛かった.
お名前.com 「DSN設定」
間違って「お申込み」のリンクの方を選んでしまうとカード情報の入力になる.
やりたかったのは「次へ」を押すとその画面が切り替わり表示される.
その中の「DNSレコード設定を利用する」の「設定する」をクリック.
お名前.com DNSレコードの設定
Aレコード」の方はうまくいったが,「AAAAレコード」の方はどこかの設定が悪いみたいでうまくいかない.


2021/02/22
Search Console の「DNS レコードでのドメイン所有権の確認」.
「以下の … DNS 設定にコピーします」を「コピー」.
お名前.com 「DNS レコードによる所有権の確認」の設定
「Value」の所に「貼り付け」.
「確認画面へ進む」,「設定する」で設定.
「Search Console」に戻り,「DNS レコードでのドメイン所有権の確認」の「確認」.
10 分程度で反映された.


2021/02/23
IPv6 関係で「DNSレコード設定」はそれ(AAAAレコード)で良かったみたい.
LAN 内では 3 つの NAS それぞれにアクセスできるようになった.
外からは,ルータの設定などがまだ足りないみたいでうまくアクセスできていない.


2021/03/09
Search Console 登録による Google からのアクセス.
mish.work を Search Console に登録

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

NAS 環境に Flask のインストール

先ず Debian 環境に Flask をインストール.
pip3 install Flask
Debian Flask インストール
サンプルの hello.py を実行,ブラウザで表示.
hello.py を実行して,ブラウザで表示


AS5202T でも同様に Flask をインストール.
pip3 install Flask
AS5202T に Flask のインストール
AS5202T で実行,表示


Synology NAS では pip のインストールから.
suto opkg install python-pip
suto opkg install python3-pip
Synology NAS に pip のインストール
Flask をインストールしてみたが …

Iwao@DS116:~/pyt_test/t_flask$ pip3 install Flask
Collecting Flask
  Using cached https://files.pythonhosted.org/packages/f2/28/2a03252dfb9ebf377f40fba6a7841b47083260bf8bd8e737b0c6952df83f/Flask-1.1.2-py2.py3-none-any.whl
Collecting click>=5.1 (from Flask)
  Using cached https://files.pythonhosted.org/packages/d2/3d/fa76db83bf75c4f8d338c2fd15c8d33fdd7ad23a9b5e57eb6c5de26b430e/click-7.1.2-py2.py3-none-any.whl
Collecting itsdangerous>=0.24 (from Flask)
  Using cached https://files.pythonhosted.org/packages/76/ae/44b03b253d6fade317f32c24d100b3b35c2239807046a4c953c7b89fa49e/itsdangerous-1.1.0-py2.py3-none-any.whl
Collecting Werkzeug>=0.15 (from Flask)
  Using cached https://files.pythonhosted.org/packages/cc/94/5f7079a0e00bd6863ef8f1da638721e9da21e5bacee597595b318f71d62e/Werkzeug-1.0.1-py2.py3-none-any.whl
Collecting Jinja2>=2.10.1 (from Flask)
  Using cached https://files.pythonhosted.org/packages/30/9e/f663a2aa66a09d838042ae1a2c5659828bb9b41ea3a6efa20a20fd92b121/Jinja2-2.11.2-py2.py3-none-any.whl
Collecting MarkupSafe>=0.23 (from Jinja2>=2.10.1->Flask)
  Using cached https://files.pythonhosted.org/packages/b9/2e/64db92e53b86efccfaea71321f597fa2e1b2bd3853d8ce658568f7a13094/MarkupSafe-1.1.1.tar.gz
    Complete output from command python setup.py egg_info:
    /opt/lib/python3.6/distutils/dist.py:261: UserWarning: Unknown distribution option: 'project_urls'
    /opt/lib/python3.6/distutils/dist.py:261: UserWarning: Unknown distribution option: 'include_package_data'
    /opt/lib/python3.6/distutils/dist.py:261: UserWarning: Unknown distribution option: 'python_requires'
    usage: -c [global_opts] cmd1 [cmd1_opts] [cmd2 [cmd2_opts] ...]
       or: -c --help [cmd1 cmd2 ...]
       or: -c --help-commands
       or: -c cmd --help

    error: invalid command 'egg_info'

    ----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-dsqn65uh/MarkupSafe/
Iwao@DS116:~/pyt_test/t_flask$ 

DS116 に Flask インストール ... エラー?


「 Command python setup.py egg_info faild with error code 1 」で検索 をかけると pip などが古いとある.
次の様にして pip などを更新.
sudo pip install –upgrade pip setuptools
Synology NAS の pip の更新と Flask のインストール

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

Win10 IIS https 化

テスト環境の IIS を https 化しようと思い,いろいろと…


当然であるが「サイトバインドの追加」で「SSL 証明書」がない.
サイトバインドの追加 SSL 証明書
NAS では Let’s Encrypt を使用しているので調べると win-acme などがあるみたい.
そこから入った https://github.com/win-acme/win-acme/releases/ から落としてやってみたが…


管理者でコマンドプロンプトを起動する必要がある.
wacs 「N」が無効


「N」を選択して進めるがエラー.

C:\Users\Iwao\AppData\Local\Temp<c:\Users\Public\Documents\Tools\win-acme.v2.1.4.710.x64.trimmed\wacs.exe

 A simple Windows ACMEv2 client (WACS)
 Software version 2.1.4.710 (RELEASE, TRIMMED)
 ACME server https://acme-v02.api.letsencrypt.org/
 IIS version 10.0
 Running with administrator credentials
 Scheduled task not configured yet
 Please report issues at https://github.com/PKISharp/win-acme

 N: Create new certificate (simple for IIS)
 M: Create new certificate (full options)
 R: Run scheduled renewals (0 currently due)
 A: Manage renewals (0 total)
 O: More options...
 Q: Quit

 Please choose from the menu: n

 Running in mode: Interactive, Simple
 No sites with host bindings have been configured in IIS. Add one in the IIS Manager or choose the plugin 'Manual input' instead.
 Target plugin IIS aborted or failed

 N: Create new certificate (simple for IIS)
 M: Create new certificate (full options)
 R: Run scheduled renewals (0 currently due)
 A: Manage renewals (0 total)
 O: More options...
 Q: Quit

 Please choose from the menu:


何かの設定が足りないのか?ちょっとわからないので他の方法で…


自己署名証明書でやってみることに.
「IIS 自己署名証明書」で検索
わかりやすかったのがここ.
Windows Server で自己署名 SSL 証明書を作成する手順

IIS マネージャーを使用した証明書の作成
IIS で SSL/TLS を 自己署名入り証明書 で 設定 する方法
「サーバー証明書」-「機能を開く」
「自己署名入り証明書の作成...」
フレンドリ名の指定


「サイトバインドの追加」に「SSL 証明書」が追加されている
LAN 内の他の PC から https で接続
これで https に対応できているかどうかのテストはできるので,今回はここまで.


いつも設定場所を忘れるので…


Microsoft VBScript 実行時エラー エラー ‘800a01ad’
ActiveX コンポーネントはオブジェクトを作成できません。
/_LIB_/L_Mainte.asp, 行 33
Microsoft VBScript 実行時エラー エラー '800a01ad'
「アプリケーション プール」-「詳細設定」-「32 ビット アプリケーションの有効化」を「True」に.
「アプリケーション プール」-「詳細設定」-「32 ビット アプリケーションの有効化」



https://jml.mish.work/index.php/various/iis.html

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

HDL-Z2WM2C2 メール設定

何時からかは不明だが HDL-Z2WM2C2 のメール設定が無効になっていたので…
メール設定 ZWS Manager
HDL-AH2W は,
LANDISK HDL-AHW メール設定
WDCloud はメールアドレスだけの指定.
WDCloud メール設定
WDCloud メール設定
DS115j
Synology NAS  DSM メール設定



https://dev.mish.work/wordpress/?s=Mail+Server

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