0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

C++ Builder > メモリが足りません (Abnormal Program Termination) 表示を別ソフトから検知する + アルファ

Last updated at Posted at 2017-12-21
動作環境
C++ Builder XE4

関連

C++ Builder > メモリが足りません (Abnormal Program Termination) > 再現方法

上記のエラーが出たソフトを探すにはどうするか。

状況としては以下になるようだ。

  • メッセージのウィンドウキャプションは「実行ファイル名(.exeなし)」になる
    • 例: Project1

code

FindWindow

Unit2.cpp
//---------------------------------------------------------------------------

#include <vcl.h>
#pragma hdrstop

#include "Unit2.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm2 *Form2;
//---------------------------------------------------------------------------
__fastcall TForm2::TForm2(TComponent* Owner)
	: TForm(Owner)
{
}
//---------------------------------------------------------------------------
void __fastcall TForm2::Button1Click(TObject *Sender)
{
	HWND hwnd;

	hwnd = FindWindow(NULL, L"Project1");
	if (hwnd == NULL) {
		return;
	}

	ShowMessage("found");
}
//---------------------------------------------------------------------------

実行例

qiita.png

qiita.png

プラスアルファ

@ うしおととら

うしおととらの行動を見てきた親しき者達に告ぐ。 これより先は見てはならぬ… 其は見ずとも良い物語。 見ずとも良い。 見れば心憂い必ずや後悔する。

注意: 下記は根本原因の解決ではありません。

「メモリが足りません。」表示に対してOKを押す処理。

Unit2.cpp
//---------------------------------------------------------------------------

#include <vcl.h>
#pragma hdrstop

#include "Unit2.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm2 *Form2;
//---------------------------------------------------------------------------
__fastcall TForm2::TForm2(TComponent* Owner)
	: TForm(Owner)
{
}
//---------------------------------------------------------------------------
void __fastcall TForm2::Button1Click(TObject *Sender)
{
	HWND hwnd;

	hwnd = FindWindow(NULL, L"Project1");
	if (hwnd == NULL) {
		return;
	}

	SetForegroundWindow(hwnd);
	keybd_event(VK_RETURN, 0, 0, 0);
}
//---------------------------------------------------------------------------
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?