LoginSignup
3
1

More than 5 years have passed since last update.

HSPで予期せぬエラーで作業中のデーターが消えるのを防ぐ

Last updated at Posted at 2018-04-07

作業データーがフリーズした後の強制終了によって消えないようにする方法。
HSPが出すエラー(エラー番号が書かれているもの)ではなく、Windowsが出すエラーに対応。

Windowsから情報の回復を求められたことを知る

Windowsから情報の回復を求められたことを知るには、Kernel32のRegisterApplicationRecoveryCallback関数でコールバック関数を登録すればよい。

//作業データーが強制終了によって失うことがないメモ帳

#uselib "kernel32.dll
#func DebugBreak "DebugBreak"
#func RegisterApplicationRecoveryCallback "RegisterApplicationRecoveryCallback" int, int, int, int
#func ApplicationRecoveryFinished "ApplicationRecoveryFinished" int
#define TRUE 1

#uselib ""
#func ApplicationRecoveryCallback "" int

#include "hscallbk.as"
setcallbk fnRecoveryCallback, ApplicationRecoveryCallback,*OnRecoveryCallback

RegisterApplicationRecoveryCallback varptr(fnRecoveryCallback), 0, 0, 0

sdim buf
mesbox buf, ginfo_winx, ginfo_winy-20, 5
button gosub "停止!", *btn
stop

*OnRecoveryCallback //情報の回復が求められた
    notesel buf
    notesave "backup.bak" //作業中のデーターを保存する
    ApplicationRecoveryFinished TRUE //作業が完了した
return 0

*btn
    DebugBreak //プログラムの実行を停止する
return

次回起動時に保存した作業中のファイルを読み込めばOK。

3
1
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
3
1