下面的是系统的字符集,不知是否是你想要的.
注释掉的那行表示是否是安装的字符集,你根据自己的需要选择吧.
radiogroup1中的三个item文字分别为:
1.Use the system defau - ANSI code page
2.Windows NT/2000/XP: Use the system defaul - Macintosh code page
3 Use the system default - OEM code page
====================================================================
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, Buttons, Menus, ExtCtrls;
type
PCPInfoEX = ^TCPInfoEx;
TCPInfoEx = record
MaxCharSize: UINT;
DefaultChar: array[0..MAX_DEFAULTCHAR - 1] of byte;
LeadByte: array[0..MAX_LEADBYTES - 1] of byte;
UnicodeDefaultChar: WChar;
CodePage: UINT;
CodePageName: array[0..MAX_PATH - 1] of Char;
end;
TForm1 = class(TForm)
Button1: TButton;
ListBox1: TListBox;
BitBtn1: TBitBtn;
Button2: TButton;
RadioGroup1: TRadioGroup;
procedure Button1Click(Sender: TObject);
procedure BitBtn1Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
private
{ Private declarations }
OEMList: TStringList;
ANSIList: TStringList;
MacintoshList: TStringList;
public
{ Public declarations }
List: TStringList;
end;
function GetCPInfoExA(CodePage: UINT; dwFalgs: DWORD; lpCPInfoEx: PCPInfoEx): bool; stdcall;
external 'Kernel32.dll';
function EnumCodePagesProc(lpCodePageString: pchar): boolean; stdcall;
var
Form1: TForm1;
implementation
{$R *.DFM}
function EnumCodePagesProc(lpCodePageString: pchar): boolean;
begin
form1.List.Add(lpCodePageString);
result := True;
end;
procedure TForm1.Button1Click(Sender: TObject);
var
i: integer;
cp: TCPInfoEx;
begin
AnsiList.Clear;
OEMList.Clear;
MacintoshList.Clear;
for i := 0 to List.Count-1 do
begin
if GetCPInfoExA(strtoint(List.Strings), CP_ACP, @cp) then
AnsiList.Add(cp.CodePageName);
if GetCPInfoExA(strtoint(List.Strings), CP_MACCP, @cp) then
MacintoshList.Add(cp.CodePageName);
if GetCPInfoExA(strtoint(List.Strings), CP_OEMCP, @cp) then
OEMList.Add(cp.CodePageName);
end;
end;
procedure TForm1.BitBtn1Click(Sender: TObject);
begin
EnumSystemCodePages(@enumcodepagesproc, CP_SUPPORTED);
// EnumSystemCodePages(@enumcodepagesproc, CP_INSTALLED);
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
List := TStringList.Create;
OEMList := TStringList.Create;
AnsiList := TStringList.Create;
MacintoshList := TStringList.Create;
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
case radiogroup1.ItemIndex of
0: listbox1.Items := AnsiList;
1: listbox1.Items := MacintoshList;
2: listbox1.Items := OEMList;
end;
end;
procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);
begin
AnsiList.Free;
OEMList.Free;
MacintoshList.Free;
end;
end.