ホーム » .NET » MFC AP で .NET の利用

2022年11月
 12345
6789101112
13141516171819
20212223242526
27282930  

カテゴリー

アーカイブ

ブログ統計情報

  • 80,460 アクセス



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.

1件のコメント

コメントは停止中です。

%d人のブロガーが「いいね」をつけました。