class LboxUnlha


  コンストラクタ




UNLHA32.DLL for windows32 をインストールする必要があります

事前定義
  

#define FNAME_MAX32		512
typedef	HGLOBAL	HARC;
typedef struct {
	DWORD 			dwOriginalSize;
 	DWORD 			dwCompressedSize;
	DWORD			dwCRC;
	UINT			uFlag;
	UINT			uOSType;	
	WORD			wRatio;
	WORD			wDate;
	WORD 			wTime;
	char			szFileName[FNAME_MAX32 + 1];
	char			dummy1[3];
	char			szAttribute[8];
	char			szMode[8];
}	INDIVIDUALINFO, *LPINDIVIDUALINFO;

typedef HARC (WINAPI *LPFUNC_OPEN_ARC)
(const HWND _hwnd, LPCSTR _szFileName,const DWORD _dwMode);
typedef int (WINAPI *LPFUNC_CLOSE_ARC)
(HARC _harc);
typedef int (WINAPI *LPFUNC_FIND_FIRST)
(HARC _harc, LPCSTR _szWildName,INDIVIDUALINFO FAR *lpSubInfo);
typedef int (WINAPI *LPFUNC_FIND_NEXT)
(HARC _harc,INDIVIDUALINFO FAR *_lpSubInfo);

typedef int (WINAPI *LPFUNC_UNLHA)
(const HWND _hwnd,LPCSTR _szCmdLine,LPSTR _szOutput,const DWORD _dwSize);
typedef int (WINAPI *LPFUNC_UNZIP)
(const HWND _hwnd,LPCSTR _szCmdLine,LPSTR _szOutput,const DWORD _dwSize);
typedef int (WINAPI *LPFUNC_ZIP)
(const HWND _hwnd,LPCSTR _szCmdLine,LPSTR _szOutput,const DWORD _dwSize);
  

  

// *********************************************************
// コンストラクタ
// *********************************************************
LboxUnlha::LboxUnlha()
{
	LboxUnlha::hArc = NULL;
	LboxUnlha::lib = NULL;
	LboxUnlha::hOwner = NULL;
	LboxUnlha::Mode = M_REGARDLESS_INIT_FILE;
	this->Output.Resize( MAX_PATH );
}
LboxUnlha::LboxUnlha( HWND hWnd )
{
	LboxUnlha::hArc = NULL;
	LboxUnlha::lib = NULL;
	LboxUnlha::hOwner = hWnd;
	LboxUnlha::Mode = M_REGARDLESS_INIT_FILE;
	this->Output.Resize( MAX_PATH );
}

// *********************************************************
// デストラクタ
// *********************************************************
LboxUnlha::~LboxUnlha()
{
	if ( LboxUnlha::hArc != NULL ) {
		UnlhaCloseArchive( LboxUnlha::hArc );
	}
	if ( LboxUnlha::lib != NULL ) {
		FreeLibrary( LboxUnlha::lib ); 
	}
}
  







  Initialize




  

// *********************************************************
// 初期化
// 戻り値 : 無し
// *********************************************************
void LboxUnlha::Initialize( void )
{
	if ( LboxUnlha::lib != NULL ) {
		return;
	}

	LboxUnlha::lib = LoadLibrary( "UNLHA32.DLL" );
	if ( LboxUnlha::lib == NULL ) {
		return;
	}

	LboxUnlha::UnlhaOpenArchive =
		(LPFUNC_OPEN_ARC)GetProcAddress(
			LboxUnlha::lib, "UnlhaOpenArchive" 
		);

	LboxUnlha::UnlhaCloseArchive =
		(LPFUNC_CLOSE_ARC)GetProcAddress(
			LboxUnlha::lib, "UnlhaCloseArchive" 
		);

	LboxUnlha::UnlhaFindFirst =
		(LPFUNC_FIND_FIRST)GetProcAddress(
			LboxUnlha::lib, "UnlhaFindFirst" 
		);

	LboxUnlha::UnlhaFindNext =
		(LPFUNC_FIND_NEXT)GetProcAddress(
			LboxUnlha::lib, "UnlhaFindNext" 
		);

	LboxUnlha::UnlhaAction =
		(LPFUNC_UNLHA)GetProcAddress(
			LboxUnlha::lib, "Unlha" 
		);
}
  

  CheckDll

  

// *********************************************************
// DLL ロードが正常かどうか
// 戻り値 : OK true, NO false
// *********************************************************
BOOL LboxUnlha::CheckDll( void )
{
	if ( LboxUnlha::lib != NULL ) {
		return true;
	}
	else {
		return false;
	}
}
  

  OpenArchive

  

// *********************************************************
// アーカイブ オープン
// 戻り値 : 成功 true, 失敗 false
// *********************************************************
BOOL LboxUnlha::OpenArchive( LPTSTR szFileName )
{
	if ( LboxUnlha::lib == NULL ) {
		return false;;
	}

	if ( LboxUnlha::hArc != NULL ) {
		LboxUnlha::CloseArchive( );
	}

	LboxUnlha::hArc = UnlhaOpenArchive(
		LboxUnlha::hOwner,
		szFileName,
		LboxUnlha::Mode
	);
	if ( LboxUnlha::hArc == NULL ) {
		return false;
	}

	return true;
}
  

  CloseArchive

  

// *********************************************************
// アーカイブ クローズ
// 戻り値 : 無し
// *********************************************************
void LboxUnlha::CloseArchive( void )
{
	if ( LboxUnlha::lib == NULL ) {
		return;
	}
	if ( LboxUnlha::hArc == NULL ) {
		return;
	}

	UnlhaCloseArchive( LboxUnlha::hArc );
	LboxUnlha::hArc = NULL;
}
  

  EnumListbox

  

// *********************************************************
// リストボックスに列挙
// 戻り値 : 成功 true, 失敗 false
// *********************************************************
BOOL LboxUnlha::EnumListbox( HWND hList, int nIndex, LPTSTR szWildName )
{
	if ( LboxUnlha::lib == NULL ) {
		return false;
	}
	if ( LboxUnlha::hArc == NULL ) {
		return false;
	}

	INDIVIDUALINFO ivinfo;
	int ret;

	ret = UnlhaFindFirst(
		LboxUnlha::hArc,
		szWildName,
		&ivinfo
	);

	char *szBuffer = new char[1024];
	ZeroMemory( szBuffer, 1024 );
	FILETIME ft;
	SYSTEMTIME st;

	while( ret == 0 ) {

		lstrcpy( szBuffer, ivinfo.szFileName );
		wsprintf( szBuffer+lstrlen(szBuffer), "\t%d",
			ivinfo.dwOriginalSize );
		wsprintf( szBuffer+lstrlen(szBuffer), "\t%d",
			ivinfo.dwCompressedSize );
		wsprintf( szBuffer+lstrlen(szBuffer), "\t%d",
			ivinfo.wRatio );

		DosDateTimeToFileTime( ivinfo.wDate, ivinfo.wTime, &ft );
		FileTimeToSystemTime( &ft, &st );
		wsprintf(
			szBuffer+lstrlen(szBuffer),
			"\t%04d/%02d/%02d %02d:%02d:%02d",
			st.wYear,
			st.wMonth,
			st.wDay,
			st.wHour,
			st.wMinute,
			st.wSecond
		);
		wsprintf( szBuffer+lstrlen(szBuffer), "\t%s",
			ivinfo.szAttribute );
		wsprintf( szBuffer+lstrlen(szBuffer), "\t%s",
			ivinfo.szMode );

		LboxListInsert( hList, nIndex, szBuffer );
		ret = UnlhaFindNext(
			LboxUnlha::hArc,
			&ivinfo
		);
		nIndex++;
	}

	delete [] szBuffer;

	return true;
}
  

  Unlha

  

// *********************************************************
// 書庫一般
// 戻り値 : 0 正常終了, それ以外はエラー
// *********************************************************
int LboxUnlha::Unlha( LboxString *LCmdLine )
{
	return LboxUnlha::Unlha(
		LCmdLine->szLboxString,
		this->Output.szLboxString,
		this->Output.nLboxString
	);
}
int LboxUnlha::Unlha(
LPTSTR szCmdLine, LPTSTR szOutput, const DWORD dwSize )
{
	if ( LboxUnlha::lib == NULL ) {
		return 1;
	}

	return UnlhaAction(
		LboxUnlha::hOwner,
		szCmdLine,
		szOutput,
		dwSize
	);
}
  

  Enum

  

// *********************************************************
// リストビューに列挙
// 戻り値 : 成功 true, 失敗 false
// *********************************************************
BOOL LboxUnlha::Enum( LboxListview *Lview, LPTSTR szWildName )
{
	if ( LboxUnlha::lib == NULL ) {
		return false;
	}
	if ( LboxUnlha::hArc == NULL ) {
		return false;
	}

	Lview->Initialize();
	Lview->AddColumn( LVCFMT_LEFT, 100, "" );
	Lview->AddColumn( LVCFMT_LEFT, 100, "ファイル名" );
	Lview->AddColumn( LVCFMT_LEFT, 100, "サイズ" );
	Lview->AddColumn( LVCFMT_LEFT, 100, "圧縮サイズ" );
	Lview->AddColumn( LVCFMT_LEFT, 100, "圧縮率" );
	Lview->AddColumn( LVCFMT_LEFT, 100, "タイムスタンプ" );
	Lview->AddColumn( LVCFMT_LEFT, 100, "属性" );
	Lview->AddColumn( LVCFMT_LEFT, 100, "モード" );
	Lview->AddColumn( LVCFMT_LEFT, 100, "ディレクトリ" );
	Lview->AddColumn( LVCFMT_LEFT, 100, "フルパス" );
	Lview->AddColumn( LVCFMT_LEFT, 100, "ソート" );

	INDIVIDUALINFO ivinfo;
	int ret;

	ret = UnlhaFindFirst(
		LboxUnlha::hArc,
		szWildName,
		&ivinfo
	);

	FILETIME ft;
	SYSTEMTIME st;
	int nCount;
	LboxString LString;

	while( ret == 0 ) {

		Lview->AddRow();

		LString.operator = (ivinfo.szFileName );
		LString.Replace( "/", "\\" );
		LString.StripPath( );
		LString.Replace( "\\", "/" );
		Lview->SetColumnText( 1, &LString );

		Lview->SetColumnPrintf( 2, "%d", ivinfo.dwOriginalSize );
		Lview->SetColumnPrintf( 3, "%d", ivinfo.dwCompressedSize );
		LString.Printf( "%d", ivinfo.wRatio );
		if ( LString.Length() > 0 ) {
			LString.Insert( ".", LString.Length()-1 );
			Lview->SetColumnText( 4, &LString );
		}

		DosDateTimeToFileTime( ivinfo.wDate, ivinfo.wTime, &ft );
		FileTimeToSystemTime( &ft, &st );
		Lview->SetColumnPrintf( 5,
			"%04d/%02d/%02d %02d:%02d:%02d",
			st.wYear,
			st.wMonth,
			st.wDay,
			st.wHour,
			st.wMinute,
			st.wSecond
		);
		Lview->SetColumnText( 6, ivinfo.szAttribute );
		Lview->SetColumnText( 7, ivinfo.szMode );

		LString.operator = (ivinfo.szFileName );
		LString.Replace( "/", "\\" );
		LString.RemoveFileSpec( );
		LString.Replace( "\\", "/" );
		Lview->SetColumnText( 8, &LString );
		if ( LString.operator == ( "" ) ) {
			LString.operator = (" ");
			LString.operator += (ivinfo.szFileName);
			Lview->SetColumnText( 10, &(LString) );
		}
		else {
			Lview->SetColumnText( 10, ivinfo.szFileName );
		}

		Lview->SetColumnText( 9, ivinfo.szFileName );

		ret = UnlhaFindNext(
			LboxUnlha::hArc,
			&ivinfo
		);
	}

	Lview->Sort( 10, 0 );
	nCount = -1;
	while( Lview->FindNextRow( &nCount ) ) {
		Lview->SetColumnPrintf( 0, "%d", nCount+1 );
	}
	Lview->Fit();
	Lview->SetColumnWidth( 10, 0 );
	return true;
}
  

  Freeze

  

// *********************************************************
// ドラッグドロップされたファイルを書庫へ登録または更新
// 戻り値 : 0 正常終了, それ以外はエラー
// *********************************************************
int LboxUnlha::Freeze( HDROP hDrop )
{
	int i,nFiles;
	LboxString LFile;

	LFile.Resize( MAX_PATH );

	nFiles = DragQueryFile(
		hDrop,
		0xFFFFFFFF,
		LFile.szLboxString,
		LFile.nLboxString
	);

	this->Command.SetChar( 0, 0 );
	this->Command.operator = ( "U -r2x " );
	LFile.operator = (&(this->TargetPath));
	LFile.Enclose('"');
	this->Command.operator += ( &(LFile) );
	this->Command.operator += ( " " );
	for( i = 0; i < nFiles; i++ ) {
		if ( i != 0 ) {
			this->Command.operator += ( " " );
		}
		DragQueryFile(
			hDrop,
			i,
			LFile.szLboxString,
			LFile.nLboxString
		);
		LFile.RemoveFileSpec();
		LFile.AddBackslash();
		LFile.Enclose( '"' );
		this->Command.operator += ( &LFile );
		this->Command.operator += ( " " );

		DragQueryFile(
			hDrop,
			i,
			LFile.szLboxString,
			LFile.nLboxString
		);
		LFile.StripPath();
		LFile.Enclose( '"' );
		this->Command.operator += ( &LFile );
	}

	return LboxUnlha::Unlha(
		&(this->Command)
	);

}
// *********************************************************
// 複数のファイルを書庫登録または更新
// 戻り値 : 0 正常終了, それ以外はエラー
// LPath は、フルパスファイルリスト ( タブ区切り )
// *********************************************************
int LboxUnlha::Freeze( LboxString *LPath )
{
	return LboxUnlha::Freeze(
		LPath->szLboxString
	);
}
int LboxUnlha::Freeze( LPTSTR lpPath )
{
	LboxToken LToken;
	LboxString LString;
	
	LToken.CreateToken( lpPath, "\t" );

	int i;

	this->Command.operator = ( "U -r2x " );
	LString.operator = (&(this->TargetPath));
	LString.Enclose('"');
	this->Command.operator += ( &(LString) );
	this->Command.operator += ( " " );
	for( i = 0; i < LToken.nCount; i++ ) {
		if ( i != 0 ) {
			this->Command.operator += ( " " );
		}
		LString.operator = (LToken.Token[i]);
		LString.RemoveFileSpec();
		LString.AddBackslash();
		LString.Enclose('"');
		this->Command.operator += (&LString);
		this->Command.operator += ( " " );
		LString.operator = (LToken.Token[i]);
		LString.StripPath();
		LString.Enclose('"');
		this->Command.operator += (&LString);
	}

	return LboxUnlha::Unlha(
		&(this->Command)
	);
}
  

  Delete

  

// *********************************************************
// リストビューの選択されている行のファイルを削除
// 戻り値 : 0 正常終了, それ以外はエラー
// *********************************************************
int LboxUnlha::Delete( LboxListview *Lview )
{
	LboxString LString;
	int nRow;
	BOOL bFirst;

	this->Command.operator = ( "D -p2 " );
	LString.operator = (&(this->TargetPath));
	LString.Enclose('"');
	this->Command.operator += ( &(LString) );
	this->Command.operator += ( " " );

	nRow = -1;
	bFirst = true;
	while( Lview->FindNextSelectedRow( &nRow ) ) {
		if ( bFirst ) {
			bFirst = false;
		}
		else {
			this->Command.operator += ( " " );
		}
		Lview->GetColumnText( 9, &LString );
		LString.Enclose('"');
		this->Command.operator += ( &(LString) );
	}

	return LboxUnlha::Unlha(
		&(this->Command)
	);
}
  

  MeltDirect

  

// *********************************************************
// リストビューの選択されている行のファイルを解凍
// 戻り値 : 0 正常終了, それ以外はエラー
// 解凍先にパス情報を反映しない
// *********************************************************
int LboxUnlha::MeltDirect( LboxListview *Lview, LboxString *LDir )
{
	return LboxUnlha::MeltDirect(
		Lview,
		LDir->szLboxString
	);
}
int LboxUnlha::MeltDirect( LboxListview *Lview, LPTSTR lpDir )
{
	LboxString LString;
	int nRow;
	BOOL bFirst;

	this->Command.operator = ( "E -p2 " );
	LString.operator = (&(this->TargetPath));
	LString.Enclose('"');
	this->Command.operator += ( &(LString) );
	this->Command.operator += ( " " );
	LString.operator = (lpDir);
	LString.AddBackslash();
	LString.Enclose('"');
	this->Command.operator += ( &(LString) );
	this->Command.operator += ( " " );

	nRow = -1;
	bFirst = true;
	while( Lview->FindNextSelectedRow( &nRow ) ) {
		if ( bFirst ) {
			bFirst = false;
		}
		else {
			this->Command.operator += ( " " );
		}
		Lview->GetColumnText( 9, &LString );
		LString.Enclose('"');
		this->Command.operator += ( &(LString) );
	}

	return LboxUnlha::Unlha(
		&(this->Command)
	);
}
  

  MeltPath

  

// *********************************************************
// リストビューの選択されている行のファイルを解凍
// 戻り値 : 0 正常終了, それ以外はエラー
// 解凍先にパス情報を反映しない
// *********************************************************
int LboxUnlha::MeltPath( LboxListview *Lview, LboxString *LDir )
{
	return LboxUnlha::MeltPath(
		Lview,
		LDir->szLboxString
	);
}
int LboxUnlha::MeltPath( LboxListview *Lview, LPTSTR lpDir )
{
	LboxString LString;
	int nRow;
	BOOL bFirst;

	this->Command.operator = ( "X -p2 " );
	LString.operator = (&(this->TargetPath));
	LString.Enclose('"');
	this->Command.operator += ( &(LString) );
	this->Command.operator += ( " " );
	LString.operator = (lpDir);
	LString.AddBackslash();
	LString.Enclose('"');
	this->Command.operator += ( &(LString) );
	this->Command.operator += ( " " );

	nRow = -1;
	bFirst = true;
	while( Lview->FindNextSelectedRow( &nRow ) ) {
		if ( bFirst ) {
			bFirst = false;
		}
		else {
			this->Command.operator += ( " " );
		}
		Lview->GetColumnText( 9, &LString );
		LString.Enclose('"');
		this->Command.operator += ( &(LString) );
	}

	return LboxUnlha::Unlha(
		&(this->Command)
	);
}
  

  MeltAll

  

// *********************************************************
// ディレクトリを作成して全て解凍
// 戻り値 : 0 正常終了, それ以外はエラー
// *********************************************************
int LboxUnlha::MeltAll(
	int nType
)
{
	LboxString LString;

	this->Output.Resize( 4096 );
	// コマンドパラメータ
	if ( nType == 0 ) {
		this->Command.operator = ( "X -p2 " );
	}
	else {
		this->Command.operator = ( "E -p2 " );
	}

	// 書庫パラメータ
	LString.operator = (&(this->TargetPath));
	LString.Enclose('"');
	this->Command.operator += ( &(LString) );
	this->Command.operator += ( " " );

	if ( this->TargetPath.operator == ("") ) {
		this->ErrMessage.operator = ("書庫が指定されていません");
		return -1;
	}

	// ディレクトリ作成
	LString.operator = (&(this->TargetPath));
	LString.RemoveExtension();
	CreateDirectory( LString.szLboxString, NULL );

	LString.AddBackslash();
	LString.Enclose('"');
	this->Command.operator += ( &(LString) );
	this->Command.operator += ( " *" );

	return this->Unlha(
		&(this->Command)
	);

}
  

  MeltDirectRow

  

int LboxUnlha::MeltDirectRow( LboxListview *Lview, int nTargetRow, LboxString *LDir )
{
	return LboxUnlha::MeltDirectRow(
		Lview,
		nTargetRow,
		LDir->szLboxString
	);
}
int LboxUnlha::MeltDirectRow( LboxListview *Lview, int nTargetRow, LPTSTR lpDir )
{
	LboxString LString;
	int nRow;
	BOOL bFirst;

	this->Command.operator = ( "E -p2 " );
	LString.operator = (&(this->TargetPath));
	LString.Enclose('"');
	this->Command.operator += ( &(LString) );
	this->Command.operator += ( " " );
	LString.operator = (lpDir);
	LString.AddBackslash();
	LString.Enclose('"');
	this->Command.operator += ( &(LString) );
	this->Command.operator += ( " " );

	Lview->SetCurrentRow( nTargetRow );
	Lview->GetColumnText( 10, &LString );
	LString.Enclose('"');
	this->Command.operator += ( &(LString) );

	return LboxUnlha::Unlha(
		&(this->Command)
	);
}
  

  MeltPathRow

  

int LboxUnlha::MeltPathRow( LboxListview *Lview, int nTargetRow, LboxString *LDir )
{
	return LboxUnlha::MeltPathRow(
		Lview,
		nTargetRow,
		LDir->szLboxString
	);
}
int LboxUnlha::MeltPathRow( LboxListview *Lview, int nTargetRow, LPTSTR lpDir )
{
	LboxString LString;
	int nRow;
	BOOL bFirst;

	this->Command.operator = ( "X -p2 " );
	LString.operator = (&(this->TargetPath));
	LString.Enclose('"');
	this->Command.operator += ( &(LString) );
	this->Command.operator += ( " " );
	LString.operator = (lpDir);
	LString.AddBackslash();
	LString.Enclose('"');
	this->Command.operator += ( &(LString) );
	this->Command.operator += ( " " );

	Lview->SetCurrentRow( nTargetRow );
	Lview->GetColumnText( 10, &LString );
	LString.Enclose('"');
	this->Command.operator += ( &(LString) );

	return LboxUnlha::Unlha(
		&(this->Command)
	);
}
  




yahoo  google  MSDN  MSDN(us)  WinFAQ  Win Howto  tohoho  ie_DHTML  vector  wdic  辞書  天気 


[cmstd]
Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; ClaudeBot/1.0; +claudebot@anthropic.com)
24/04/19 19:03:51
InfoBoard Version 1.00 : Language=Perl

1 BatchHelper COMprog CommonSpec Cprog CprogBase CprogSAMPLE CprogSTD CprogSTD2 CprogWinsock Cygwin GameScript HTML HTMLcss InstallShield InstallShieldFunc JScript JScriptSAMPLE Jsfuncs LLINK OldProg OracleGold OracleSilver PRO PRObrowser PROc PROconePOINT PROcontrol PROftpclient PROjscript PROmailer PROperl PROperlCHAT PROphp PROphpLesson PROphpLesson2 PROphpLesson3 PROphpfunction PROphpfunctionArray PROphpfunctionMisc PROphpfunctionString PROsql PROvb PROvbFunction PROvbString PROvbdbmtn PROvbonepoint PROwebapp PROwin1POINT PROwinSYSTEM PROwinYOROZU PROwindows ProjectBoard RealPHP ScriptAPP ScriptMaster VBRealtime Vsfuncs a1root access accreq adsi ajax amazon argus asp aspSample aspVarious aspdotnet aw2kinst cappvariety centura ckeyword classStyle cmaterial cmbin cmdbapp cmenum cmlang cmlistbox cmstd cmstdseed cmtxt cs daz3d db dbCommon dbaccess dnettool dos download flex2 flex3 flex4 framemtn framereq freeWorld freesoft gimp ginpro giodownload google hdml home hta htmlDom ie9svg install java javaSwing javascript jetsql jquery jsp jspTest jspVarious lightbox listasp listmsapi listmsie listmsiis listmsnt listmspatch listmsscript listmsvb listmsvc memo ms msde mysql netbeans oraPlsql oracle oracleWiper oraclehelper orafunc other panoramio pear perl personal pgdojo pgdojo_cal pgdojo_holiday pgdojo_idx pgdojo_ref pgdojo_req php phpVarious phpguide plsql postgres ps r205 realC realwebapp regex rgaki ruby rule sboard sc scprint scquest sdb sdbquest seesaa setup sh_Imagick sh_canvas sh_dotnet sh_google sh_tool sh_web shadowbox shgm shjquery shvbs shweb sjscript skadai skywalker smalltech sperl sqlq src systemdoc tcpip tegaki three toolbox twitter typeface usb useXML vb vbdb vbsfunc vbsguide vbsrc vpc wcsignup webanymind webappgen webclass webparts webtool webwsh win8 winofsql wmi work wp youtube