#ifndef gramH
#define gramH

#include <vcl\Classes.hpp>
#include <vcl\Controls.hpp>
#include <vcl\StdCtrls.hpp>
#include <vcl\Forms.hpp>
#include <vcl\ExtCtrls.hpp>
#include <vcl\graphics.hpp>

struct	Gra
{
//SjisToUnicode(wchar_t *unicode, const char* sjis, const size_t count)
	int		err;
	HANDLE			handle;
	Gra		*next;
void CALLBACK _export pascal (*GetNkfVersion)(LPSTR verStr);
int CALLBACK _export pascal (*SetNkfOption)(LPCSTR optStr);
void CALLBACK _export pascal (*NkfConvert)(LPSTR outStr,LPCSTR inStr) ;
void CALLBACK _export pascal (*ToHankaku)(LPSTR inStr) ;			// (V1.02)
void CALLBACK _export pascal (*ToZenkakuKana)(LPSTR outStr,LPCSTR inStr) ;	// (V1.02)
void CALLBACK _export pascal (*EncodeSubject)(LPSTR outStr,LPCSTR inStr) ;	// (V1.03)

	Gra()
    {
		handle = NULL;
        next = NULL;
    };

// Destructor
	~Gra()
    {
    	if (handle != NULL) {
        	FreeLibrary(handle);					// ライブラリ解放
        }
    };

// ********** DLL Procedure address set *********
	bool	load_library(void)
    {
    	bool	ret = false;

		handle = LoadLibrary("NKF32.DLL");					// Win32 API

    	if (handle != NULL) {
    		// === Win32 API でアドレス取得 ===
			(void *)GetNkfVersion= GetProcAddress(handle, "GetNkfVersion");
                        (void *)SetNkfOption= GetProcAddress(handle, "SetNkfOption");
                        (void *)NkfConvert= GetProcAddress(handle, "NkfConvert");
                        (void *)ToHankaku= GetProcAddress(handle, "ToHankaku");
                        (void *)ToZenkakuKana= GetProcAddress(handle, "ToZenkakuKana");
                        (void *)EncodeSubject= GetProcAddress(handle, "EncodeSubject");

            // === 簡易エラーチェック ===
/*			ret = (IsSupported != NULL) & (GetPicture != NULL);
            if (ret == false)
            	err = GetLastError();*/ret=true;
        }
        return	ret;
    };

};

#endif
