2013년 1월 27일 일요일

DataSnap REST 에서 한글(utf8) 사용

DataSnap REST 에서 한글(utf8)을 사용하려고 Template의 html의 헤더에
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
을 포함하여도 한글이 제대로 표현되지 않습니다.

예전에 WebBroker 에서 한글처리하기 위하여서는
해당 엑션에서
Response.ContentType := 'text/html; charset=utf-8';
Response.ContentEncoding := 'utf-8';
지정하여 하였었습니다.

DataSnap Rest 에서는
WebModuleUnit1.pas 에서


procedure TWebModule1.WebModuleBeforeDispatch(Sender: TObject;
  Request: TWebRequest; Response: TWebResponse; var Handled: Boolean);
begin
  Response.ContentType := 'text/html; charset=utf-8'; // 추가
  Response.ContentEncoding := 'utf-8'; //추가
  if FServerFunctionInvokerAction <> nil then
    FServerFunctionInvokerAction.Enabled := AllowServerFunctionInvoker;
end;


하여서 해결하였습니다.


2013년 1월 24일 목요일

windows7 에서 엑셀 2007 xls adoquery로 읽기

windows7 에서 엑셀 2007 xls adoquery로 읽기위하여는

폼에 AdoQuery를 올려 놓고 ConnectionString 에
Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\Users\Administrator\Desktop\Example2.xls;Extended Properties=Excel 12.0;
와 같이 입력하면 됩니다.

단, 엑셀에서 데이터 베이스로 설정 할 영역을 이름을 주어야 합니다.
그런후 Sql 에 Select * from name  where 1
와 같은 방법으로 접근하면 됩니다.

2013년 1월 18일 금요일

특정 폴더 찾기


uses WinApi.Shlobj, ActiveX;

procedure TForm2.Button1Click(Sender: TObject);
var
  PIDL: PItemIDList;
  // Path: String;
  Path: PChar;
  Folder: integer;
  AMalloc: IMalloc;
begin
  Folder:= CSIDL_INTERNET_CACHE;
  // SetLength(Path,MAX_PATH);
  Path:= StrAlloc(Max_Path);
  SHGetSpecialFolderLocation(Application.Handle, Folder, PIDL);
  // if SHGetPathFromIDList(PIDL, pChar(Path)) then
  if SHGetPathFromIDList(PIDL, Path) then
    Edit1.Text:= Path;
  SHGetMalloc(AMalloc);
  StrDispose(Path);
end;

Path 변수를 String 과 PChar 2가지의 방법으로 구현하여 보았습니다.
당연 String 으로 할 경우에는 StrDispose 가 필요없습니다.

ShellListView 에서 필터 구현하기

ShellListView 컴포넌트는 델파이 샘플프로그램에 있으니 설치하면 됩니다.

저의 경우에는
C:\Users\Public\Documents\RAD Studio 9.0 Samples\Delphi\VCL\ShellControls
에 있습니다.

폼에 FilterComboBox 와 ShellListView 컴포넌트를 올려 놓습니다.


unit Unit2;

interface

uses
  Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
  Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls, Vcl.FileCtrl, Vcl.ExtCtrls, Vcl.ComCtrls, Vcl.Shell.ShellCtrls;

type
  TForm2 = class(TForm)
    ShellListView1: TShellListView;
    Panel1: TPanel;
    Label1: TLabel;
    Edit1: TEdit;
    Button1: TButton;
    FilterComboBox1: TFilterComboBox;
    procedure ShellListView1AddFolder(Sender: TObject; AFolder: TShellFolder;
      var CanAdd: Boolean);
    procedure FilterComboBox1Change(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form2: TForm2;

implementation

{$R *.dfm}

procedure TForm2.FilterComboBox1Change(Sender: TObject);
begin
  ShellListView1.Refresh;
end;

procedure TForm2.ShellListView1AddFolder(Sender: TObject; AFolder: TShellFolder;
  var CanAdd: Boolean);
var xFilterExt, xExt : string;
begin
  if FilterComboBox1.Mask <> '*.*' then begin
    xFilterExt:= ExtractFileExt(FilterComboBox1.Mask);
    xExt:= ExtractFileExt(AFolder.PathName);
    if (CompareText(xExt, xFilterExt) = 0) or AFolder.IsFolder then
      CanAdd:= True
    else
      CanAdd:= False;
  end;

end;

end.

tensorflow gpu 사용하기에서

 tensorflow 설치시 주의해야 한다. # Anything above 2.10 is not supported on the GPU on Windows Native python - m pip install "tensorflow<2.11...