ホーム » Iwao の投稿 (ページ 51)

作者アーカイブ: Iwao

2024年4月
 123456
78910111213
14151617181920
21222324252627
282930  

カテゴリー

アーカイブ

ブログ統計情報

  • 80,105 アクセス



2038 対応

以下の様なコードの所では,VC 7 までは 2038 に対応していない.
time_t ????::Get???? (void)
{
  ….
  time_t term = 0 ;
  #if(_MFC_VER >= 0x0800)
    ReadBlock(…,sizeof(__time32_t)/sizeof(WORD)) ;
    __time32_t* dateBuffer = (__time32_t*)Get????Buffer() ;
    __time32_t term32 = *dateBuffer ;
    term = UINT(term32) ;
  #else
    ReadBlock(…,sizeof(time_t)/sizeof(WORD)) ;
    time_t* dateBuffer = (time_t*)Get????Buffer() ;
    term = *dateBuffer ;
  #endif
  return term ;
  }
0x7fffffff までは問題ないが,2038 を超えると VC 7 の場合,-2147483648 になる.
VC 7 LocTim64.c では,以下の様になっている.
  if ( (*ptime _MAX__TIME64_T) )
    return( NULL );
VC 6 では,long のため範囲外(LocalTim.c など)となる.
VC 8 では,2038/01/19 と認識できる.
なんで VC 8 で #ifdef としたのか?古いことなので覚えてないが,VC 7 では一部うまくないことがあったため 2038 には対応しないとした?

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

Dependency Walker , Spy , …

Dependency Walker
 http://www.dependencywalker.com/

Spy++ 8.0
 2005-09-28 10:07 140,463 spyxx.chm
 2005-12-01 03:24 496,824 spyxx.exe
 2005-09-23 02:13 73,728 spyxxhk.dll
 VC++ 2005 SP1 再頒布可能パッケージ
Is this 投稿 useful? Useful Useless 0 of 0 people say this 投稿 is useful.

ASP 関係続き...

ログ
 AsFile.FileSys.Log(LPCTSTR message) { return ::LogMessage(message) ; }

TempFile
 AsFile.FileSys.GetDirTemp() + “TempFile.txt”
  logData = oFSys.TextFileRead(logFile)
  logData = logData & Now & vbTab & “LogData” & vbCrLf
  oFSys.TextFileWrite logFile,logData

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

しばらく使ってなかったので,…

並び替え
  ”SELECT * FROM Table_H_T_M_ ORDER BY U_1,U_2 ;”
  ”SELECT * FROM Table_H_T_M_ ORDER BY T_New,U_1,U_2 ;”
  ”SELECT * FROM Table_H_T_M_ ORDER BY T_Max,U_1,U_2 ;”
  ”SELECT * FROM Table_H_T_M_ ORDER BY H_No,U_1,N_ ;”

今回やりたいのは抽出なので WHERE
  ”SELECT * FROM Table_H_T_M_ WHERE H_No < 'M1000' ORDER BY H_No,U_1,N_ ;"
  "SELECT * FROM Table_H_T_M_ WHERE H_No LIKE ‘M0%’ ORDER BY H_No,U_1,N_ ;"

RecodeCount が -1 で返される
  デフォルトのカーソル adOpenForwardOnly
  ADO Recordset で RecordCount プロパティが -1 を返す場合
  oRS.CursorLocation = 3 ‘ adUseClient などとすれば良い
  または,oRS.Open source , connection , 3

全レコードの読み取り
  dim oRS
  set oRS = Server.CreateObject(“ADODB.recordset”)
  oRS.Open “Table” , “DSN=name”
  oRS.MoveFirst
  do while not oRS.EOF
    …
    oRS.MoveNext
  loop
  …
  oRS.Close

ASP の中止
  Response.End

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

CString::ReleaseBuffer で Assert

CString::GetBuffer を使用して,ReleaseBuffer を忘れているバグがあった.
現象は,内容をコピーした別の CString で ReleaseBuffer した時にアサート.
—————————
Microsoft Visual C++ Debug Library
—————————
Debug Assertion Failed!
Program: …\…\TInet\Debug.060\TInet.exe
File: strcore.cpp
Line: 512
For information on how your program can cause an assertion
failure, see the Visual C++ documentation on asserts.
(Press Retry to debug the application)
—————————
中止(A) 再試行(R) 無視(I)
—————————
CString::ReleaseBuffer で Assert

他にも,GetLength で 0 になる.
CString::GetLength()  で 0 になる

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

DoDragDrop ですぐに抜ける?

以下の様なコードで,COleDataSource::DoDragDrop の部分がすぐ抜ける.
  CStringArray sa ;
  ::ListBoxToStringArray(m_DropList,&sa,TRUE) ;
  {
    CByteArray ba ;
    ::StringArrayToString2Z(sa,&ba) ;
    int len = ba.GetSize() ;
    HDROP hDrop = (HDROP)::GlobalAlloc(GHND,sizeof(DROPFILES) + len + sizeof(TCHAR)) ;
    if (hDrop == NULL) { return ; }
    LPDROPFILES lpdf = (LPDROPFILES)::GlobalLock(hDrop) ;
    lpdf->pFiles= sizeof(DROPFILES) ;
    lpdf->pt.x = 0 ;
    lpdf->pt.y = 0 ;
    lpdf->fNC = FALSE ;
    lpdf->fWide = FALSE ;
    #ifdef _UNICODE
    lpdf->fWide = TRUE ;
    #endif
    LPCTSTR lpFileNames = LPCTSTR(LPCSTR(lpdf)+lpdf->pFiles) ;
    memmove(LPVOID(lpFileNames),ba.GetData(),len) ;
    ::GlobalUnlock(hDrop) ;
    {
      COleDataSource* ods = new COleDataSource ;
      ods->CacheGlobalData(CF_HDROP,hDrop) ;
      ods->DoDragDrop() ;
      delete ods ;
      }
    }

AfxOleInit() を呼出していなかった.


[VC50] Windows 95 標準コントロールのドラッグアンドドロップサンプル 
http://support.microsoft.com/kb/152092/ja


2014/08/11 追記
上のコードで,delete ods はうまくない.
データ オブジェクトとデータ ソース : 作成と破棄

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

Win 7 TaskBar Pin

C:\Users\[UserName]\AppData\Roaming\Microsoft\Internet Explorer\Quick Launch\User Pinned\TaskBar

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

LBS_HASSTRINGS を忘れると…

オーナ描画リストボックスで,GetText を呼出した時
LBS_HASSTRINGS を忘れると
コントロールの LBS_HASSTRINGS が指定されていない.


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

CInternetFile::ReadString

CInternetFile::ReadString
CInternetFile::ReadString
VC 6 UNICODE.exe で,文字化けと,中身がうまく処理されない.MBCS.exe はOK.
文字化けは,CHAR から TCHAR への変換を正しく処理することにより対応.
それでも,まだ改行の位置で戻らず,終端も正しくない(デバッグ版ではゴミ ‘0xCD’ が入る).
どうも,VC 6 や 7 では,うまく処理できないみたい.VC 8 では期待した動作と思われる.

  CHttpConnection* pServer = pServer = session.GetHttpConnection (svrName) ;
  CHttpFile* pFile = pServer->OpenRequest (CHttpConnection::HTTP_VERB_GET,name) ;
  pFile-> SendRequest () ;
  {
    CString buf ;
    while (pFile->ReadString(buf)) {
      CString tmp = ::ToStringTC(LPCSTR(LPCTSTR(buf))) ;
      rBuf.Add(tmp) ;
      }
    ::StringArrayToString(rBuf,rData) ;
    }

http://support.microsoft.com/kb/329071
Microsoft KB Archive/329071
 PRB: CInternetFile::ReadString Does Not Convert Non-Unicode Text to Unicode Text


2019/01/31 LPCSTR , LPCWSTR からの変換
CRT_MBWC.hxx
tstrmbwc.hxx


2022/09/09 CHttpFile Read String

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

MS11-025 その後

以前,KB2465367 などの影響を受けたが,その対応版 KB2538218 のコードの抜粋
typedef BOOL (WINAPI *PFNFINDACTCTXSECTIONSTRING)(DWORD, const GUID *, ULONG, LPCTSTR, PACTCTX_SECTION_KEYED_DATA);
static HINSTANCE _AfxLoadLangDLL(LPCTSTR pszFormat, LPCTSTR pszPath, LCID lcid)
{
 TCHAR szLangDLL[_MAX_PATH+14];
 TCHAR szLangCode[4];
 HINSTANCE hInstance = NULL;
 if (lcid == LOCALE_SYSTEM_DEFAULT) {
  Checked::tcscpy_s(szLangCode, _countof(szLangCode), _T("LOC"));
  }
 else {
  int nResult;
  nResult = ::GetLocaleInfo(lcid, LOCALE_SABBREVLANGNAME, szLangCode, 4);
  if (nResult == 0)
    return NULL;
  ASSERT( nResult == 4 );
  }
 int ret;
 ATL_CRT_ERRORCHECK_SPRINTF(ret = _sntprintf_s(szLangDLL,_countof(szLangDLL),_countof(szLangDLL)-1,pszFormat,pszPath,szLangCode));
 if(ret == -1 || ret >= _countof(szLangDLL)) {
  ASSERT(FALSE);
  return NULL;
  }
 TCHAR *pszFilename = ::PathFindFileName(szLangDLL);
 ACTCTX_SECTION_KEYED_DATA data = {sizeof(data)};
 HMODULE hKernel = GetModuleHandle(_T("KERNEL32"));
 PFNFINDACTCTXSECTIONSTRING pfnFindActCtxSectionString = NULL;
 if (hKernel != NULL) {
  #ifdef _UNICODE
   pfnFindActCtxSectionString = (PFNFINDACTCTXSECTIONSTRING)GetProcAddress(hKernel, "FindActCtxSectionStringW");
  #else
   pfnFindActCtxSectionString = (PFNFINDACTCTXSECTIONSTRING)GetProcAddress(hKernel, "FindActCtxSectionStringA");
  #endif
  }
 if (pfnFindActCtxSectionString &&
 pfnFindActCtxSectionString(0, NULL, ACTIVATION_CONTEXT_SECTION_DLL_REDIRECTION, pszFilename, &data)) {
  // Load using the dll name only…
  hInstance = ::LoadLibraryEx(pszFilename, NULL, 0);
  }
 else {
  // Load using the full path…
  hInstance = ::LoadLibraryEx(szLangDLL, NULL, 0);
  }
 return hInstance;
 }

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

コンソール AP リンクエラー

——————–構成: XXxxXXxx – Win32 Debug——————–
コンパイル中…
XXxxXXxx.cpp
リンク中…
nafxcwd.lib(thrdcore.obj) : error LNK2001: 外部シンボル “__endthreadex” は未解決です
nafxcwd.lib(thrdcore.obj) : error LNK2001: 外部シンボル “__beginthreadex” は未解決です
Debug/XXxxXXxx.exe : fatal error LNK1120: 外部参照 2 が未解決です。
link.exe の実行エラー

XXxxXXxx.exe – エラー 3、警告 0

「C/C++」-「コード生成」-「使用するランタイムライブラリ」を 「マルチスレッド (デバッグ)」 に


 
——————–構成: XXxxXXxx – Win32 Debug——————–
コンパイル中…
XXxxXXxx.cpp
リンク中…
nafxcwd.lib(afxmem.obj) : error LNK2005: “void __cdecl operator delete(void *)” (??3@YAXPAX@Z) はすでに LIBCMTD.lib(dbgdel.obj) で定義されています
Debug/XXxxXXxx.exe : fatal error LNK1169: 1 つ以上の複数回定義されているシンボルが見つかりました
link.exe の実行エラー

XXxxXXxx.exe – エラー 2、警告 0

http://support.microsoft.com/kb/148652/ja
Visual C++ で CRT ライブラリおよび MFC ライブラリのリンク順序が正しくないときに LNK2005 エラーが発生する

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

ドロップしたフォルダを開く

「ドロップされたファイルのフォルダを開く」ツールの改良版

http://cid-535f5973454c1292.office.live.com/self.aspx/.Public/Tools/DropOpen.2011.08.10.zip


i_Tools

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

ListBoxDocMF の使い方で...

以前の,画像付ファイル名リストボックス(ListBoxDocMF)の利用方法の改良
前の方法では,対応する画像(EMF)が存在しない,または見つからないと,意図した動作にならない.
そのため,ファイルを登録する時に,対応画像が存在しないとそれを作成して登録する方法.
DImageS::Draw を利用している.
BOOL CDropOpenDlg::UpdateDImgLB()
{
  CWaitCursor wait ;
  ::TrimSameString(DropFiles) ;
  {
    static DelFileE dfe ;
    DImgAry.RemoveAll() ;
    long len = 0 ;
    int makeCount = 5 ;
    for (int dIndex=0 ; dIndex0) {
        dfe.Add(mfName) ;
        MetaFile mf(FALSE) ;
        CWnd* mainWnd = AfxGetMainWnd() ;
        CRect rect(0,0,100,100) ;
        if (!mf.Create(mainWnd,rect,mfName)) { return FALSE ; }
        CMetaFileDC* mfDC = mf.GetMetaDC() ;
        {
          dImg.Draw(mfDC,rect) ;
          }
        mf.Close() ;
        makeCount– ;
        dfe.Add(::GetFileDir(mfName)) ;
        }
      DImgAry.Add(dImg) ;
      len = max(len,dropFile.GetLength()) ;
      }
    m_CtrlDropFiles.ResetContent() ;
    for (int rIndex=0 ; rIndex<DImgAry.GetSize() ; rIndex++) {
      CString fileName = DImgAry.GetAt(rIndex).GetFileName() ;
      m_CtrlDropFiles.AddString(fileName,fileName) ;
      CString mfName = CacheFile::GetCF_Name(fileName,1000) ;
      if (::FileIsExist(mfName)) {
        m_CtrlDropFiles.SetAtDocMF(rIndex,mfName) ;
        }
      else {
        HICON icon = DImageS_GetIcon(fileName) ;
        m_CtrlDropFiles.SetAtIcon(rIndex,icon) ;
        }
      }
    ::SetHorizontalExtent(&m_CtrlDropFiles,len) ;
    }
  return TRUE ;
  }
画像付ファイル名リストボックス(ListBoxDocMF)

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

List.exe 起動時,アプリケーションエラー

以前は通っていたデバッグ用 exe をビルドしたら,起動時にアプリケーションエラーになってしまった.

原因は,アプリケーションクラス内に確保された Profile .
なぜ宣言されていたのかは今となっては不明.
ListApp.h 内をコメントにして OK .

以下が初期化される前に Profile::GetInt が通ることによりエラーとなる.
_CriticalS_ Profile::CS ;

またこのタイミング(アプリケーションクラスのコンストラクタ)では,SetRegistoryKey が指定されていないので,Profile クラスを利用すること自体がうまくないと思われる.

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

DECLARE_SERIAL を忘れると…

IMPLEMENT_SERIAL (T_BaseDoc, CObject,0) の所で
C:\…\T_BDDoc.cpp(63) : error C2039: ‘CreateObject’ : ‘T_BaseDoc’ のメンバではありません。
    c:\…\t_bd_.hpp(28) : ‘T_BaseDoc’ の宣言を確認してください。
C:\…\T_BDDoc.cpp(63) : error C2509: ‘_GetBaseClass’ : このメンバ関数は、’T_BaseDoc’ クラス内で宣言されていません。
C:\…\T_BDDoc.cpp(63) : error C2039: ‘classT_BaseDoc’ : ‘T_BaseDoc’ のメンバではありません。
    c:\…\t_bd_.hpp(28) : ‘T_BaseDoc’ の宣言を確認してください。
C:\…\T_BDDoc.cpp(63) : error C2039: ‘CreateObject’ : ‘T_BaseDoc’ のメンバではありません。
    c:\…\t_bd_.hpp(28) : ‘T_BaseDoc’ の宣言を確認してください。
C:\…\T_BDDoc.cpp(63) : error C2509: ‘GetRuntimeClass’ : このメンバ関数は、’T_BaseDoc’ クラス内で宣言されていません。
C:\…\T_BDDoc.cpp(63) : error C2039: ‘classT_BaseDoc’ : ‘T_BaseDoc’ のメンバではありません。
    c:\…\t_bd_.hpp(28) : ‘T_BaseDoc’ の宣言を確認してください。
C:\…\T_BDDoc.cpp(63) : error C2039: ‘classT_BaseDoc’ : ‘T_BaseDoc’ のメンバではありません。
    c:\…\t_bd_.hpp(28) : ‘T_BaseDoc’ の宣言を確認してください。
 

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

FileWait(ar) ;

FileWait::FileWait (CArchive& ar)
{
 CFile* file = ar.GetFile() ;
 UINT flag = ar.IsStoring() ? CFile::modeWrite : CFile::modeRead ;
 CString filePath = file->GetFilePath() ;
 Init(filePath,flag) ;
 }
 ar.IsStoring の時,書込んでいる事をレジストリにマーク(Open_WriteMode)する.

FileWait::IsOpenedWrite により,この状態を判断できる.
実際これを利用しているのは MakeCMF.cpp と,PlnCtrl.exe .
BOOL MakeCacheMF::CanMakeMF (void)
{
 …
 BOOL canMake = TRUE ;
 if (!CheckInstall()) { canMake = FALSE ; }
 else if (FileWait::IsOpenedWrite()) { canMake = FALSE ; }
 else {  …  }
 if (!canMake) {
  CString stmsg = _T(“生成を中断しています.”) ;
  …
  }
 return canMake ;
 }

BOOL SleepOtherSaving (void) {
 …
 return FileWait::IsOpenedWrite() ;
 }

LRESULT CPlnctrlDlg::FindHandler(WPARAM param1, LPARAM param2) {
 …
 if (::SleepOtherSaving()) { return 0 ; }
 …
 }

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

「最近使ったもの」が表示されなくなった

以下に存在するファイルの削除で対応.
%AppData%\Microsoft\Windows\Recent\CustomDestinations
%AppData%\Microsoft\Windows\Recent\AutomaticDestinations

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

スリープする様になった?

設定を変更したつもりはないのに,…
それと,いじってしまったのかはっきりしないが,「休止状態」がなくなった.
スリープと休止状態: よく寄せられる質問

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

VHD の圧縮でエラー 67

VHD の圧縮でエラーになる様になった.
[Window Title]
Windows Virtual PC
[Content]
予期しないエラー (67) が発生しました。
[OK]
VHD 圧縮 エラー 67

VPCTemporary_x.vht はそれなりのサイズ.
これを別のフォルダにコピーして,VHD にリネーム,仮想マシンとして追加すると,それなりに動作している.
どうも最後のリネームの段階で失敗しているみたい.

原因は,「WD SmartWare」が影響しているみたい.
バックアップ機能を一時的に止めることで回避.

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

DP340XPP 仮想環境

DP340XPP を移行した Virtual PC 内の環境
「Luna が有効にならない」は特に困るわけではない.Disk2VHD を使用した時はちゃんと表示できてたのにな~.
1.ブート時のChkDsk
2.Outlook Express
3.プロテクトデバイスを使用する AP
4.不要なファイルを整理,削除
5.ディスク クリーンアップ
6.デフラグ 1 回目
7.デフラグ 2 回目  ここでブルースクリーン

イベントビューアで Disk のエラーが多数あり
8.ChkDsk
9.デフラグ
10.PreCompact.exe
11.VHD の圧縮

DP340XPP-0.vhd 64.3 GB → 56.4 GB
DP340XPP-1.vhd 24.6 GB → 22.8 GB

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