MessageBox

概要

ソース

  • Win32MsdBox.zip
    #!/usr/bin/perl
    
    use strict;
    use warnings;
    use utf8;
    use Encode;
    use Win32::Unicode::Native;
    use Win32::API;
    
    #my $charsetFile	= 'UTF-8';
    my $charsetConsole	= 'CP932';
    my $charsetApiA		= 'CP932';
    my $charsetApiW		= 'UTF-16LE';
    
    my $message = "Hello, world!\nこんにちは世界?";
    my $type = 0x0000_0004 | 0x0000_0020;
    
    print "コンソール\n${message}\n";
    
    my $messageBoxA = Win32::API::More->new(
    	'User32',
    	'int MessageBoxA(HWND hWnd, LPCTSTR lpText, LPCTSTR lpCaption, UINT uType)'
    ) or die(decode($charsetConsole, Win32::FormatMessage(Win32::GetLastError())));
    my $retA = $messageBoxA->Call(
    	0, encode($charsetApiA, $message), encode($charsetApiA, "ApiA 版"), $type
    );
    print "${retA}\n";
    
    my $win32w = Win32::API::More->Import(
    	'User32',
    	'int MessageBoxW(HWND hWnd, LPCTSTR lpText, LPCTSTR lpCaption, UINT uType)'
    ) or die(decode($charsetConsole, Win32::FormatMessage(Win32::GetLastError())));
    my $retW = MessageBoxW(
    	0, encode($charsetApiW, $message), encode($charsetApiW, "ApiW 版"), $type
    );
    print "${retW}\n";
    
    # EOF

郵政バーコード

概要

ソース

  • YuBar.zip
  • Rolan社の YuBar.dll がインストールされていないと動作しません。
  • 住所データベースは架空のものであって、実在の人物、住所とは関係ありません。
    # 郵政バーコード作成 (Rolan社 YuBar)
    # 郵便カスタマーバーコード開発キット http://www.rolan.co.jp/shouhin/s_yubar.html
    
    use strict;
    use warnings;
    use utf8;
    use encoding 'Shift_JIS';
    use Win32::API;
    #use Data::Dump 'dump';
    
    my $FileIn  = 'Customer.txt';	# 入力ファイル
    my $FileOut = 'Customer2.txt';	# 出力ファイル
    
    open( IN, "<:encoding(Shift_JIS)", $FileIn ) || die( "can't open'".$FileIn."'.\n" );
    open( OUT, ">:encoding(Shift_JIS)", $FileOut ) || die( "can't open'".$FileOut."'.\n" );
    
    # ヘッダ行解析
    my $Line = <IN>;
    $Line =~ /(\s+)$/;
    $/ = $1;			# 改行コード設定
    chomp( $Line );
    my @Fields = split( "\t", $Line );
    my $i = 0;
    #my %FN2I = ();			# FieldName to Index
    #foreach $_ ( @Fields ){
    #	$_ =~ s/^"(.*)"$/$1/;
    #	$FN2I{ $_ } = $i++;
    #}
    my %FN2I = map{ s/^"(.*)"$/$1/; $_ => $i++; } @Fields;
    
    #print dump( %FN2I );
    
    print OUT $Line . "\t\"YuBar\"\n";
    
    my( @Records, $ZipCode, $Street, $YuBar );
    
    while( $Line = <IN> ){
    	chomp( $Line );
    	@Records = split( "\t", $Line );
    	$ZipCode = $Records[ $FN2I{ 'ZipCode' } ];
    	$ZipCode =~ s/^"(.*)"$/$1/;
    	$Street  = $Records[ $FN2I{ 'Addr2'   } ];
    	$Street  =~ s/^"(.*)"$/$1/;
    	$YuBar   = &YuBar( $ZipCode, $Street );
    	printf OUT ( "%s\t\"%s\"\n", $Line, $YuBar );
    }
    
    close( IN );
    close( OUT );
    
    exit();
    
    sub YuBar
    {
    	my( $ZipCode, $Street ) = @_;
    	my $GetYuBar = new Win32::API("YuBar",  "YubinBarcode", 'PPP', 'I');
    	my $YuBarStr = "\x00" x 23;
    	my $Ret = ($GetYuBar->Call($ZipCode, $Street, $YuBarStr) & 0xFFFF);
    	return $YuBarStr;
    }
    
    # EOF

リンク