コメント |
WSH から PHP を呼び出すサンプルです。
PHP は、php.exe にパスが通っている必要があります。
( php.ini の allow_url_include を On にして下さい )
php_com_dotnet.dll を有効にする必要があります
@DIV
<JOB>
<COMMENT>
************************************************************
WEB WSH 実行スケルトン
★★★ PDF 作成 ★★★
************************************************************
</COMMENT>
<COMMENT>
************************************************************
外部スクリプト定義
************************************************************
</COMMENT>
<SCRIPT
language="VBScript"
src="http://lightbox.in.coocan.jp/laylaClass.vbs">
</SCRIPT>
<SCRIPT language=VBScript>
' ***********************************************************
' 処理開始
' ***********************************************************
Call laylaFunctionTarget( "http://lightbox.in.coocan.jp/" )
Call laylaLoadFunction( "baseFunction.vbs" )
target = SelectDir( "対象フォルダを選択して下さい" )
if target = "" then
Wscript.Quit
end if
strParam = "$DIR," & Replace( ScriptDir, "\", "\\" )
strParam = strParam & ",$TARGET," & Replace(target, "\", "\\")
Call RunPhpParam( "TargetList", False, strParam )
</SCRIPT>
<COMMENT>
************************************************************
実行する PHP ( php.exe にパスが通っている必要があります )
php5 でテストしています
php.ini の allow_url_include を On にして下さい
************************************************************
</COMMENT>
<RESOURCE id="TargetList">
<![CDATA[
<?php
error_reporting(E_ALL & ~E_DEPRECATED);
require("https://lightbox.sakura.ne.jp/in/phppdf/japanese.txt");
$GLOBALS['margin'] = 5;
$pdf = new PDF_Japanese( 'P', 'mm', 'A4' );
$pdf->AddSJISFont("MSPGothic");
$pdf->AddPage();
# 塗りつぶす為の色
$pdf->SetFillColor( 200, 230, 185 );
# タイトル印字
$pdf->SetFont('SJIS','B',20);
$text = 'ディレクトリ容量の表示';
$pdf->Text( $GLOBALS['margin'], 13.5, $text );
# 通常印字フォント
$pdf->SetFont('SJIS','',10);
# ページ内の印字開始高さ
$pdf->Ln(10);
$Fso = new COM("Scripting.FileSystemObject");
$Folder = $Fso->GetFolder("$TARGET");
$SubFolder = $Folder->SubFolders;
$pdf->SetX( $GLOBALS['margin'] );
$pdf->SetTextColor( 0, 0, 255 );
$pdf->Cell( 100, 6, "ディレクトリ名称" , 1, 0, 'C', 1 );
$pdf->SetTextColor( 0, 0, 0 );
$pdf->Cell( 20, 6, "サイズ", 1, 0, 'C', 0 );
$pdf->Ln();
foreach($SubFolder as $obj) {
$pdf->SetX( $GLOBALS['margin'] );
$pdf->SetTextColor( 0, 0, 255 );
$pdf->Cell( 100, 6, $obj->Name, 1, 0, 'L', 1 );
$pdf->SetTextColor( 0, 0, 0 );
try {
$pdf->Cell( 20, 6, trim((floor($obj->Size / 1000) / 1000)), 1, 0, 'R', 0 );
}
catch( Exception $e ) {
$pdf->Cell( 20, 6, "エラー", 1, 0, 'L', 1 );
}
$pdf->Ln();
}
$pdf->Output("$DIR\\sample.pdf");
# **********************************************************
# Windows 経由の 外部実行
# **********************************************************
$WshShell = new COM("WScript.Shell");
$command = "RunDLL32.EXE shell32.dll,ShellExec_RunDLL ";
$command .= "\"$DIR\\sample.pdf\"";
$WshShell->Run( $command, 1, TRUE );
print "処理が終了しました\n";
?>
]]]]>
</RESOURCE>
</JOB>
@END |