//--------------------------------------------------------------------------- #define NO_WIN32_LEAN_AND_MEAN 'API #include #include #include #include #include "Unit1.h" #include "hamlog50.h" //--------------------------------------------------------------------------- #pragma package(smart_init) #pragma resource "*.dfm" #pragma hdrstop #pragma pack(8) TForm1 *Form1; FILE *fp_w; typedef int (WINAPI *GETVER)(void); typedef int (WINAPI *HLOPEN)(int (* Func)(char *), TThLog *, const char *, const int); typedef int (WINAPI *HL_RD)(TThLog *, const long, const int); typedef void (WINAPI *HLCLOSE)(TThLog *, const int); HINSTANCE hDll ; TThLog *Th; static GETVER Getver; static HLOPEN Hlopen; static HL_RD Hl_rd; static HLCLOSE Hlclose; //変数宣言 AnsiString currentDir , hdb_name; //--------------------------------------------------------------------------- __fastcall TForm1::TForm1(TComponent* Owner) : TForm(Owner) { } //--------------------------------------------------------------------------- void __fastcall TForm1::Button1Click(TObject *Sender) { // hdbファイルの読み込み OpenDialog1->Filter = "Hamlog Ver5.0 (*.hdb)|*.hdb"; if (OpenDialog1->Execute()) Edit1->Text = ExpandFileName(OpenDialog1->FileName); hdb_name = Edit1->Text; } //--------------------------------------------------------------------------- void __fastcall TForm1::Button3Click(TObject *Sender) { exit(0); } //--------------------------------------------------------------------------- void __fastcall TForm1::Button2Click(TObject *Sender) { AnsiString dll_name , hl_name ; int len , ret , count ; // Hamlog50.dllのロード // プログラムと同じフォルダから読み込む hDll = LoadLibrary("Hamlog50.dll"); // HAMLOG.hdbと同じ場所を探す if (hDll==NULL){ dll_name = hdb_name ; len = dll_name.Length(); dll_name.SetLength(len-4); dll_name += "50.dll" ; hDll = LoadLibrary(dll_name.c_str()); } if (hDll==NULL){ ShowMessage("Hamlog50.dll を読み込めませんでした。\n\nもう一度、HAMLOG.hdbファイルを選択するか、\nもしくは、起動中のHamlogソフトを終了させて下さい。"); } // dllのバージョンチェック Getver = (GETVER)GetProcAddress(hDll,"GetThdllVersion"); if (Getver() < 0x50300){ ShowMessage("Hamlog50.dll のバージョンが5.03よりも古いです。\n新しいdllを入手して下さい。"); } // DLL内の関数を取得 Hlopen = (HLOPEN)GetProcAddress(hDll,"HamlogOpen"); Hl_rd = (HL_RD)GetProcAddress(hDll,"THW_read"); Hlclose = (HLCLOSE)GetProcAddress(hDll,"HamlogClose"); // メモリーの確保 Th = (struct TThLog *)malloc(sizeof(struct TThLog) * 2 ); // HAMLOGをオープンします。 hl_name = hdb_name ; len = hl_name.Length(); hl_name.SetLength(len-4); ret = (*Hlopen)( NULL , Th , hl_name.c_str() , 1 ); if( ret == LDBF_NOPEN ){ ShowMessage("HAMLOG.HDB をオープンできませんでした。\n\nもう一度HAMLOGファイルを選んでください。\nもしくは、起動中のHamlogを終了させて下さい。"); return ; } //ここからが、hamlogデータの読み込み部です int ii ; //データ数を数える count = 1 ; while( (*Hl_rd)( Th , count , 4 ) == SUCCESS ){ ++count; } char buff[700] ; fp_w = fopen("hldata.csv","w+") ; //交信順番の場合は、 for ( ii = 1 ; ii < count-1 ; ++ii ){ //最近の交信を先に書き出す。 for ( ii = count-1 ; ii >=1 ; --ii ){ (*Hl_rd)( Th , ii , 4 ) ; strcpy( buff , Th->Qso.Calls ); strcat( buff , "," ); strcat( buff , Th->Qso.Date ); strcat( buff , "," ); // strcat( buff , Th->Qso.Time ); // strcat( buff , "," ); // strcat( buff , Th->Qso.Hiss ); // strcat( buff , "," ); // strcat( buff , Th->Qso.Myrs ); // strcat( buff , "," ); strcat( buff , Th->Qso.Freq ); strcat( buff , "," ); strcat( buff , Th->Qso.Mode ); strcat( buff , "," ); // strcat( buff , Th->Qso.Code ); // strcat( buff , "," ); // strcat( buff , Th->Qso.Glid ); // strcat( buff , "," ); // strcat( buff , Th->Qso.Qsl ); // strcat( buff , "," ); // strcat( buff , Th->Qso.Name ); // strcat( buff , "," ); // strcat( buff , Th->Qso.Qth ); // strcat( buff , "," ); strcat( buff , Th->Qso.Rmk1 ); // strcat( buff , "," ); // strcat( buff , Th->Qso.Rmk2 ); fprintf(fp_w,"%s\n",buff) ; } fclose( fp_w ); ShowMessage( "hldata.csvファイルを作成しました。" ); // メモリーの解放 (*Hlclose)( Th , 0 ); FreeLibrary(hDll); free( Th ); } //---------------------------------------------------------------------------