Posted by Gu Youn
,
Indy 설치 및 사용에 관한 포스트로 시간이 날 때마다 업데이트 할 예정이다.

(1). Install Indy For C+ Builder
1. BCB Library & Incude Path 설정
  ㄱ. Tools->Environment Options->Library Path에 아래의 두 경로를 추가한다.
   a . Indy Source 디렉토리
   b. 컴파일된 dcu와 hpp 헤더 디렉토리

  ㄴ. Project->Options->Library Path에는 컴파일된 dcu와 hpp 헤더 경로추가한다.  
  ㄷ. Project->Options->Include Path에는 hpp 헤더 경로를 추가한다.

(2). Indy 관련된 포스트
1.BCB에 설치된 Indy가 이상하게 동작 할때...(http://kr.blog.yahoo.com/guyoun/83.html)

2.C++ Builder 6에 Indy 10 설치 하기(http://kr.blog.yahoo.com/guyoun/82.html)
Posted by Gu Youn
,

1. Request처리
IRequest는 QueryString와 Form으로 처리.
TWebRequest는 QueryFields와 ContentFields로 처리.

2. 소스

TRequestType = (ireq,webreq);

var
FIRequest : IRequest;
FWebRequest : TWebRequest;
FRequestType : TRequestType;

Function GetParameter(paramName : String): String;
begin
  if FRequestType = ireq then
  begin
      Result := String(FIRequest.QueryString.Item[paramName]);

      if Result = '' then
        Result := String(FIRequest.Form.Item[paramName]);
  end
  else if FRequestType = webreq then
  begin
      Result := FWebRequest.QueryFields.Values[paramName];
     
      if Result = '' then
        Result := FWebRequest.ContentFields.Values[paramName];
  end;

end;

Posted by Gu Youn
,

1. Wed,11-Dec-2002 04:31:50 GMT 형식의 시간 문자열 만들기

2. 소스
uses sysutils;

Function GetFormatedDate:String;
var
  expireDate : TDateTime;
  format : TFormatSettings;
  day : integer;
begin
format.ShortDayNames[1] := 'Sun';
format.ShortDayNames[2] := 'Mon';
format.ShortDayNames[3] := 'Tue';
format.ShortDayNames[4] := 'Wed';
format.ShortDayNames[5] := 'Thu';
format.ShortDayNames[6] := 'Fri';
format.ShortDayNames[7] := 'Sat';

format.LongMonthNames[1] := 'Jan';
format.LongMonthNames[2] := 'Feb';
format.LongMonthNames[3] := 'Mar';
format.LongMonthNames[4] := 'Apr';
format.LongMonthNames[5] := 'May';
format.LongMonthNames[6] := 'Jun';
format.LongMonthNames[7] := 'Jul';
format.LongMonthNames[8] := 'Aug';
format.LongMonthNames[9] := 'Sep';
format.LongMonthNames[10] := 'Oct';
format.LongMonthNames[11] := 'Nov';
format.LongMonthNames[12] := 'Dec';

format.TimeSeparator := ':';

expireDate := Now-10;
day := DayOfWeek(expireDate);
Result := format.ShortDayNames[day]  + FormatDateTime(', dd-mmmm-yyyy hh:mm:ss', expireDate, format) + ' GMT';
end;

Posted by Gu Youn
,
1.소개 : URL(http://www.daum.net/test/test.html)에서 Domain(daum.net)을 분리하는 함수.
Indy의 TIdURI를 사용하면 쉽게 구현됨

2.소스 :
function ParseDomain(url:String):String;
var
  domain,host: String;
  len,pos1 : integer;
  IdURI : TIdURI;
begin
  pos1 := Pos('http://',url);
  if pos1 = 0 then
    url := 'http://' + url;

  IdURI := TIdURI.Create(url);

  host := IdURI.Host;
  pos1 := Pos('.',host)+1;
  len := StrLen(PChar(host));
  domain := MidStr(host,pos1,len-pos1+1);

  if IdURI <> nil then
      IdURI.Free;

  Result := domain;
end;
Posted by Gu Youn
,
1. 설명
ㄱ. com으로 등록해서 CreateObject를 함수 이용해서 vb dll의 특정 함수를 호출한다.
ㄷ. Import Type Library를 이용해서 컴포넌트로 등록하고 사용할 수 있다.

2. 소스
-Decrypt라는 함수를 호출하는 예-
  Variant userObj;
  userObj = Variant::CreateObject("Crypto.Crypto2");
  Variant name = userObj.OleFunction("Decrypt","O/bNd{Me?");
Posted by Gu Youn
,
1. String -> WideChar[] 변환

개념 : MultiByteToWideChar API를 이용한다.

소스 :
    var
        data : String;
        someunicode : array of widechar;
        len : integer;
    begin
        data := '안녕하세요.';
        len := StrLen(PChar(data));
        MultiByteToWideChar(CP_ACP, 0, PChar(data), -1, @someunicode[0], len);
    end;


2. String <-> WIdeString
개념 : 델파이에서는 자동 형변환 되므로 신경 쓸 필요 없음

소스 :
델코 민성기 님 작성
http://www.delphikorea.com/board/zboard/view.php?id=qa&page=1&sn1=&divpage=1&sn=off&ss=on&sc=on&keyword=유니코드&select_arrange=headnum&desc=asc&no=20996

var

WStr : WideString;

SStr : String;



TempStr1, TempStr2 : String;

i : Integer;

begin

WStr := '얼러리꼴러리!';
SStr := WStr;
//이렇게 해도 결과 같음
//SStr :='얼레리꼴러리!';
//Wstr := WIdeString(SStr);


for i:= 1 to Length(WStr) do
begin
TempStr1 := TempStr1 + '$' + IntToHex(Ord(WStr[i]), 2);
if i <> Length(WStr) then TempStr1 := TempStr1 + ', ';
end;

for i:= 1 to Length(SStr) do
begin
TempStr2 := TempStr2 + '$' + IntToHex(Ord(SStr[i]), 2);
if i <> Length(SStr) then TempStr2 := TempStr2 + ', ';
end;

ShowMessage(
Format(
'유니코드 "%s", 길이 %d'#13'%s'
+#13#13+
'일반문자 "%s", 길이 %d'#13'%s',
  [WStr, Length(WStr), TempStr1, SStr, Length(SStr), TempStr2]
)
);

end;

Posted by Gu Youn
,
Posted by Gu Youn
,