ホーム » 2024 » 7月

月別アーカイブ: 7月 2024

2024年7月
 123456
78910111213
14151617181920
21222324252627
28293031  

カテゴリー

アーカイブ

ブログ統計情報

  • 92,983 アクセス


VC6 から VC2022 への移行

VC 6 から 2022 へのアップグレードがなくなったので,手動での移行方法を試してみた.


「新しいプロジェクトの作成」で「空のプロジェクト」を選択して「次へ」
「新しいプロジェクトの作成」で「空のプロジェクト」を選択して「次へ」
適当なプロジェクト名を付けて「作成」.
プロジェクト名を入力して「作成」
必要に応じて,VC 6 プロジェクトのファイルをコピー.
VC 6 プロジェクトのファイルをコピー


「ソリューション エクスプローラー」のプロジェクトを「右クリック」-「追加」-「既存の項目」.
cpp,h,rc を追加
cpp,h,rc を選択して「追加」.


必要に応じて「出力ディレクトリ」などの指定.
「出力ディレクトリ」などの指定
「共有 DLL で MFC を使う」に.
「共有 DLL で MFC を使う」を選択
「_CONSOLE」を「_WINDOWS」に.
「_CONSOLE」を「_WINDOWS」に
「Windows(/SUBSYSTEM:WINDOWS)」に.
「Windows(/SUBSYSTEM:WINDOWS)」を選択


ヘッダーファイルを追加していないと「クラス ウィザード」がうまく機能しない.


以下は,正しく設定されていない場合のエラー.

C:\...\afx.h(24,1): error C1189: #error:  Building MFC application with /MD[d] (CRT dll version) requires MFC shared dll version. Please #define _AFXDLL or do not use /MD[d]

「スタティック ライブラリで MFC を使用する」または「共有 DLL で MFC を使う」に.


libcmtd.lib(exe_main.obj) : error LNK2019: 未解決の外部シンボル _main が関数 "int __cdecl invoke_main(void)" (?invoke_main@@YAHXZ) で参照されました

「Windows (/SUBSYSTEM:WINDOWS)」に.


クラス ウィザードで CAboutDlg のみ.
クラス ウィザード  CAboutDlg
ソリューションに *.h を追加する.


* 他の動作はまだ確認中です.

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

「バージョン情報」ダイアログ

バージョンリソースを読み込み「バージョン情報」ダイアログの表示で使用するコード.
バージョンリソースを読み込み「バージョン情報」ダイアログに設定
IDD_ABOUTBOX の IDC_STATIC を IDC_FV_DESCRIPTION_VERSION と IDC_FV_LEGAL_COPYRIGHT に変更.
???Dlg.cpp で次をインクルード.
  #include  "FVerDlg.hxx"
  #include  "i_trace.hxx"
次の様に OnInitDialog に ::SetAboutFileVer を追加.
  BOOL CAboutDlg::OnInitDialog()
  {
     CDialog::OnInitDialog();
     ::SetAboutFileVer(this->GetSafeHwnd()) ;
     return TRUE;
     }

https://itl.mish.work/i_Tools/Doc/blog/vc/AboutB.zip

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

¥¥(コンピュータ名) を開く

\\(ComputerName) を開きたいと思い,次の様なコードを書いた.

{
	tstring	self_name = _T("\\\\") + ::GetComputerName() + _T("\\") ;
	S_Exec	se ;
	se.SetFile(self_name.c_str()) ;
	se.Execute() ;
	}

これはこれでうまく動作するが,それを perplexity に問い合わせると
::ShellExecute エクスプローラ 自分自身をネットワーク名で開く

#include <windows.h>
#include <shellapi.h>

int main()
{
    TCHAR computerName[MAX_COMPUTERNAME_LENGTH + 1];
    DWORD size = sizeof(computerName) / sizeof(computerName[0]);
    
    // コンピューター名を取得
    if (GetComputerName(computerName, &size))
    {
        // ネットワークパスを構築
        TCHAR networkPath[MAX_PATH];
        wsprintf(networkPath, TEXT("\\\\%s"), computerName);
        
        // ShellExecuteを使用してエクスプローラーを起動
        ShellExecute(NULL, TEXT("open"), TEXT("explorer.exe"), networkPath, NULL, SW_SHOWNORMAL);
    }

    return 0;
}

そのままで動作するコードが表示されている.

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

コンソール AP のアイコン

以前,コンソール AP にアイコンなどのリソースを追加する方法はいろいろとやった.
それを今回,動作時にアイコンを変更できないかと…
最初 Copilot で問合わせたがうまい情報は引っ掛からなかった.
それで今度は最近利用し始めた perplexity で…
「Windows cpp で コンソール AP のアイコンを指定する方法と動的に変更する方法」と入力.
perplexity  SetConsoleIcon
kernel32 にある SetConsoleIcon が使えるらしい.
それで次の様なコードを書いてみたが…

BOOL WINAPI SetConsoleIcon(HICON hIcon)
{
    typedef BOOL (WINAPI *SetConsoleIconFn)(HICON);
    static SetConsoleIconFn setConsoleIcon = NULL;

    if (setConsoleIcon == NULL)
    {
        HMODULE hKernel32 = GetModuleHandleA("kernel32.dll");
        if (hKernel32 == NULL) return FALSE;

        setConsoleIcon = (SetConsoleIconFn)GetProcAddress(hKernel32, "SetConsoleIcon");
        if (setConsoleIcon == NULL) return FALSE;
        }
    return setConsoleIcon(hIcon);
    }

bool    test    (c_tstring& str)
{
    std::terr << str << std::endl ;
    ::pause(10) ;
    HICON   hIcn2 = ::LoadIcon(::GetModuleHandle(NULL), MAKEINTRESOURCE(IDI_ICON2)) ;
    HICON   hIcn3 = ::LoadIcon(::GetModuleHandle(NULL), MAKEINTRESOURCE(IDI_ICON3)) ;
    {
        HWND    hWnd  = ::GetConsoleWindow() ;
        ::SendMessage(hWnd,WM_SETICON,TRUE, (LPARAM)hIcn2) ;
        ::SendMessage(hWnd,WM_SETICON,FALSE,(LPARAM)hIcn2) ;
        }
    ::pause(20) ;
    {
        SetConsoleIcon(hIcn3) ;
        }
    ::pause(30) ;
    return  true ;
    }

Win7 や 8.1 ではうまく変更できたが,Win10 や 11 では変更できなかった.

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

FBX SDK 2020.3.7

FBX SDKダウンロードページを見ると 2020.3.7 があった.
インストールしてみると,今までと lib 以下が異なる.
2020.3.4 までは VS のバージョンでわかれていたのに,今回は lib\x64\debug\ などになっている.
FBX SDK 2020.3.7
ビルドしてのテストなどはまた今度落ち着いた時に …


設定などは次の所に書いています.
https://jml.mish.work/index.php/cpp/fbx-sdk-setting.html


FBX Review は exe が置いてあった.
Autodesk FBX Review – Windows 64 Bit

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

QNAP AI Core 3.4.1

先日から QNAP NAS のパッケージのアップデートがある.
幾つかは問題なく更新できるのに AI Core 3.4.0 のみが更新に失敗する.
今までは特に問題なく更新できていた(関連するものは自動で更新されていた)のに…


イベントログを見ると,次の様になっている.

エラー  2024-06-29 18:35:45  Iwao 192.168.1.xx Qmanager    Qmanager/2...  App Center App Installation  [App Center] Failed to install QuMagieCore. You must first install container-station.
エラー  2024-07-09 15:58:59  Iwao 192.168.1.xx Web Desktop Mozilla/5.0    App Center App Installation  [App Center] Failed to install QuMagieCore. You must first install container-station.

どうも Container Station を先に更新しないといけないみたい.
Container Station を更新してから AI Core の更新でうまくいった.
QNAP AI Core 3.4.1 に更新できない?

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

warning C4786

VC 6 でビルドしているとよく出力される C4786

--------------------Configuration: T_prm_c - Win32 Debug--------------------
Compiling...
T_prm_c.cpp
c:\program files (x86)\microsoft visual studio\vc98\include\utility(21) : warning C4786: 'std::pair<std::basic_string<char,std::char_traits<char>,std::allocator<char> > const *,std::basic_string<char,std::char_traits<char>,std::allocator<char> > con
st *>::pair<std::basic_string<char,std::char_traits<char>,std::allocator<char> > const *,std::basic_string<char,std::char_traits<char>,std::allocator<char> > const *>' : identifier was truncated to '255' characters in the debug information
Linking...
T_prm_c.exe - 0 error(s), 1 warning(s)

warning C4786
最初の頃は場所が限定てきていたので #pragma warning (… : 4786 ) で切り替えていた.
がそのうち,プロジェクトによっては StdAfx.h で対応する様になった.


古くからのプロジェクトで,直接はこれらの対応を行っていない(共通のヘッダでの対応)プロジェクトが幾つもある.
コンパイル単位ではほとんど C4786 は出力されないが,一部のソースで出力され,また限定できたのでそのメモ.

--------------------Configuration: BlockIn - Win32 Debug--------------------
Compiling...
SMastSel.cpp
c:\program files (x86)\microsoft visual studio\vc98\mfc\include\afxtempl.h(63) : warning C4786: 'std::vector<std::vector<std::basic_string<char,std::char_traits<char>,std::allocator<char> >,std::allocator<std::basic_string<char,std::char_traits<char
>,std::allocator<char> > > >,std::allocator<std::vector<std::basic_string<char,std::char_traits<char>,std::allocator<char> >,std::allocator<std::basic_string<char,std::char_traits<char>,std::allocator<char> > > > > >' : identifier was truncated to '
255' characters in the debug information
SMastSel.obj - 0 error(s), 1 warning(s)

ソースに #pragma warning (disable : 4786 ) を追加して,更にそのヘッダがインクルードしているものをソースに追加.
warning C4786  AfxTempl.h
これで AfxTempl.h をインクルードしているヘッダファイルが限定できた.


iostream を使用している場合も,その前に disable : C4786 が必要みたいだが,その場合は簡単には見つけられない?
warning C4786  iostream


他には fstream ,string .

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