2011년 10월 31일 월요일

특수문자열 표


키보드에 특수문자열 변경 키가 없는경우 유용한 특수문자열 표



! ' , .  ̄ : ; ‥ … ¨ 〃 ­ ― ∥ \ ∼ ´ ~ ˇ ˘ ˝ ˚ ˙ ¸ ˛ ¡ ¿ ː

" ( ) [ ] { } ‘ ’ “ ” 〔 〕 〈 〉 《 》 「 」 『 』 【 】

+ - < = > ± × ÷ ≠ ≤ ≥ ∞ ∴ ♂ ♀ ∠ ⊥ ⌒ ∂ ∇ ≡ ≒ ≪ ≫ √ ∽ ∝ ∵ ∫ ∬ ∈ ∋ ⊆ ⊇ ⊂ ⊃ ∪ ∩ ∧ ∨ ¬ ⇒ ⇔ ∀ ∃ ∮ ∑ ∏

$ % ₩ F ′ ″ ℃ Å ¢ £ ¥ ¤ ℉ ‰ ? ㎕ ㎖ ㎗ ℓ ㎘ ㏄ ㎣ ㎤ ㎥ ㎦ ㎙ ㎚ ㎛ ㎜ ㎝ ㎞ ㎟ ㎠ ㎡ ㎙ ㏊ ㎍ ㎎ ㎏ ㏏ ㎈ ㎉ ㏈ ㎧ ㎨ ㎰ ㎱ ㎲ ㎳ ㎴ ㎵ ㎶ ㎷ ㎸ ㎹ ㎀ ㎁ ㎂ ㎃ ㎄ ㎺ ㎻ ㎼ ㎽ ㎾ ㎿ ㎐ ㎑ ㎒ ㎓ ㎔ Ω ㏀ ㏁ ㎊ ㎋ ㎌ ㏖ ㏅ ㎭ ㎮ ㎯ ㏛ ㎩ ㎪ ㎫ ㎬ ㏝ ㏐ ㏓ ㏃ ㏉ ㏜ ㏆

# & * @ § ※ ☆ ★ ○ ● ◎ ◇ ◆ □ ■ △ ▲ ▽ ▼ → ← ↑ ↓ ↔ 〓 ◁ ◀ ▷ ▶ ♤ ♠ ♡ ♥ ♧ ♣ ⊙ ◈ ▣ ◐ ◑ ▒ ▤ ▥ ▨ ▧ ▦ ▩ ♨ ☏ ☎ ☜ ☞ ¶ † ‡ ↕ ↗ ↙ ↖ ↘ ♭ ♩ ♪ ♬ ㉿ ㈜ № ㏇ ™ ㏂ ㏘ ℡ ? ª º

─ │ ┌ ┐ ┘ └ ├ ┬ ┤ ┴ ┼ ━ ┃ ┏ ┓ ┛ ┗ ┣ ┳ ┫ ┻ ╋ ┠ ┯ ┨ ┷ ┿ ┝ ┰ ┥ ┸ ╂ ┒ ┑ ┚ ┙ ┖ ┕ ┎ ┍ ┞ ┟ ┡ ┢ ┦ ┧ ┩ ┪ ┭ ┮ ┱ ┲ ┵ ┶ ┹ ┺ ┽ ┾ ╀ ╁ ╃ ╄ ╅ ╆ ╇ ╈ ╉ ╊

㉠ ㉡ ㉢ ㉣ ㉭ ㉥ ㉦ ㉧ ㉨ ㉩ ㉪ ㉫ ㉬ ㉭ ㉮ ㉯ ㉰ ㉱ ㉲ ㉳ ㉴ ㉵ ㉶ ㉷ ㉸ ㉹ ㉺ ㉻ ㈀ ㈁ ㈂ ㈃ ㈄ ㈅ ㈆ ㈇ ㈈ ㈉ ㈊ ㈋ ㈌ ㈍ ㈎ ㈏ ㈐ ㈑ ㈒ ㈓ ㈔ ㈕ ㈖ ㈗ ㈘ ㈙ ㈚ ㈛

ⓐ ⓑ ⓒ ⓓ ⓔ ⓕ ⓖ ⓗ ⓘ ⓙ ⓚ ⓛ ⓜ ⓝ ⓞ ⓖ ⓠ ⓡ ⓢ ⓣ ⓤ ⓥ ⓦ ⓧ ⓨ ⓩ ① ② ③ ④ ⑤ ⑥ ⑦ ⑧ ⑨ ⑩ ⑪ ⑫ ⑬ ⑭ ⑮ ⒜ ⒝ ⒞ ⒟ ⒠ ⒡ ⒢ ⒣ ⒤ ⒥ ⒦ ⒧ ⒨ ⒩ ⒪ ⒫ ⒬ ⒭ ⒮ ⒯ ⒰ ⒱ ⒲ ⒳ ⒴ ⒵ ⑴ ⑵ ⑶ ⑷ ⑸ ⑹ ⑺ ⑻ ⑼ ⑽ ⑾ ⑿ ⒀ ⒁ ⒂

0 1 2 3 4 5 6 7 8 9 ⅰ ⅱ ⅲ ⅳ ⅴ ⅵ ⅶ ⅷ ⅸ ⅹ Ⅰ Ⅱ Ⅲ Ⅳ Ⅴ Ⅵ Ⅶ Ⅷ Ⅸ Ⅹ

½ ⅓ ⅔ ¼ ¾ ⅛ ⅜ ⅝ ⅞ ¹ ² ³ ⁴ ⁿ ₁ ₂ ₃ ₄

ㄱ ㄲ ㄳ ㄴ ㄵ ㄶ ㄷ ㄸ ㄹ ㄺ ㄻ ㄼ ㄽ ㄾ ㄿ ㅀ ㅁ ㅂ ㅃ ㅄ ㅅ ㅆ ㅇ ㅈ ㅉ ㅊ ㅋ ㅌ ㅍ ㅎ ㅏ ㅐ ㅑ ㅒ ㅓ ㅔ ㅕ ㅖ ㅗ ㅘ ㅙ ㅚ ㅛ ㅜ ㅝ ㅞ ㅟ ㅠ ㅡ ㅢ ㅣ

ㅥ ㅦ ㅧ ㅨ ㅩ ㅪ ㅫ ㅬ ㅭ ㅮ ㅯ ㅰ ㅱ ㅲ ㅳ ㅴ ㅵ ㅶ ㅷ ㅸ ㅹ ㅺ ㅻ ㅼ ㅽ ㅾ ㅿ ㆀ ㆁ ㆂ ㆃ ㆄ ㆅ ㆆ ㆇ ㆈ ㆉ ㆊ ㆋ ㆌ ㆍ ㆎ

A B C D E F G H I J K L M N O P Q R S T U V W X Y Z a b c d e f g h i j k l m n o p q r s t u v w x y z

Α Β Γ Δ Ε Ζ Η Θ Ι Κ Λ Μ Ν Ξ Ο Π Ρ Σ Τ Υ Φ Χ Ψ Ω α β γ δ ε ζ η θ ι κ λ μ ν ξ ο π ρ σ τ υ φ χ ψ ω

2011년 10월 14일 금요일

Delphi 날짜 함수 정리


//일자를 추출한다.
function DateOf(const AValue: TDateTime): TDateTime;

//시간을 추출한다.
function TimeOf(const AValue: TDateTime): TDateTime;

//평년,윤년을 구분하다.
function IsInLeapYear(const AValue: TDateTime): Boolean;

//오전,오후를 구분한다.
function IsPM(const AValue: TDateTime): Boolean;

//Word형의 년,월,일 파라메타의 유효성을 체크한다.
function IsValidDate(const AYear, AMonth, ADay: Word): Boolean;

//Word형의 시,분,초,밀리초 파라메타의 유효성을 체크한다.
function IsValidTime(const AHour, AMinute, ASecond, AMilliSecond: Word): Boolean;

//Word형의 년,월,일,시,분,초,밀리초 파라메타의 유효성을 체크한다.
function IsValidDateTime(const AYear, AMonth, ADay, AHour, AMinute, ASecond, AMilliSecond: Word): Boolean;

//ex) IsValidDateDay(2006,45) : 2006년의 45번째날이 유효한지를 체크한다.
function IsValidDateDay(const AYear, ADayOfYear: Word): Boolean;

//ex) IsValidDateWeek(2006,42) : 2006년의 42주차가 유효한지를 체크한다.
function IsValidDateWeek(const AYear, AWeekOfYear, ADayOfWeek: Word): Boolean;

//년,월,월의주차,요일 이 유효한지를 체크한다.
//ex) IsValidDateMonthWeek(2006,2,1,2) : 2006년 2월의 1주차의 화요일이 유효한지를 체크한다.
function IsValidDateMonthWeek(const AYear, AMonth, AWeekOfMonth, ADayOfWeek: Word): Boolean;

//ex) WeeksInYear(Today) : 오늘이 년의 몇주차인지 리턴한다.
function WeeksInYear(const AValue: TDateTime): Word;
function WeeksInAYear(const AYear: Word): Word;

//ex) DaysInYear(Today) : 오늘이 년의 몇일째인지 리턴한다.
function DaysInYear(const AValue: TDateTime): Word;
function DaysInAYear(const AYear: Word): Word;

//) DaysInMonth(Today) : 해당월에 몇일까지 있는지 리턴한다.
function DaysInMonth(const AValue: TDateTime): Word;
function DaysInAMonth(const AYear, AMonth: Word): Word;

//AValue의 값이 오늘이면 True를 리턴한다.
function IsToday(const AValue: TDateTime): Boolean;

//AValue, ABasis 같은날이면 True를 리턴한다.
function IsSameDay(const AValue, ABasis: TDateTime): Boolean;


//년을 추출한다.
function YearOf(const AValue: TDateTime): Word;

//월을 추출한다.
function MonthOf(const AValue: TDateTime): Word;

//년의 몇주차인지를 추출한다.
function WeekOf(const AValue: TDateTime): Word;

//일자만 추출한다.
//ex) DayOf(StrToDate('2006-06-27')) : 27을 리턴한다.
function DayOf(const AValue: TDateTime): Word;

//시간을 추출한다(24시간단위)
function HourOf(const AValue: TDateTime): Word;

//분을 추출한다.
function MinuteOf(const AValue: TDateTime): Word;

//초를 추출한다.
function SecondOf(const AValue: TDateTime): Word;

//밀리초를 추출한다.
function MilliSecondOf(const AValue: TDateTime): Word;

//년도의 시작일
function StartOfTheYear(const AValue: TDateTime): TDateTime;
function StartOfAYear(const AYear: Word): TDateTime;

//년도의 마지막일
function EndOfTheYear(const AValue: TDateTime): TDateTime;
function EndOfAYear(const AYear: Word): TDateTime;

//월의 시작일
function StartOfTheMonth(const AValue: TDateTime): TDateTime;
function StartOfAMonth(const AYear, AMonth: Word): TDateTime;

//월의 마지막일
function EndOfTheMonth(const AValue: TDateTime): TDateTime;
function EndOfAMonth(const AYear, AMonth: Word): TDateTime;

//주의 시작일
function StartOfTheWeek(const AValue: TDateTime): TDateTime;

//주의 시작일(기준요일을 정할수 있다.)
//1:월요일, 2:화요일, 3:수요일, 4:목요일 ,5:금요일 , 6:토요일 ,7:일요일
function StartOfAWeek(const AYear, AWeekOfYear: Word; const ADayOfWeek: Word = 1): TDateTime;

//주의 마지막일
function EndOfTheWeek(const AValue: TDateTime): TDateTime;

//주의 마지막일(기준요일을 정할수 있다.)
//1:월요일, 2:화요일, 3:수요일, 4:목요일 ,5:금요일 , 6:토요일 ,7:일요일
function EndOfAWeek(const AYear, AWeekOfYear: Word; const ADayOfWeek: Word = 7): TDateTime;



function StartOfTheDay(const AValue: TDateTime): TDateTime;
function StartOfADay(const AYear, AMonth, ADay: Word): TDateTime; overload;
function StartOfADay(const AYear, ADayOfYear: Word): TDateTime; overload;
function EndOfTheDay(const AValue: TDateTime): TDateTime;
function EndOfADay(const AYear, AMonth, ADay: Word): TDateTime; overload;
function EndOfADay(const AYear, ADayOfYear: Word): TDateTime; overload;


//ex) MonthOfTheYear(Today) : 오늘일자를 Word형으로 리턴한다.
function MonthOfTheYear(const AValue: TDateTime): Word;

//ex) WeekOfTheYear(Today) : 오늘일자가 몇주차인지를 Word형으로 리턴한다.
function WeekOfTheYear(const AValue: TDateTime): Word; overload;
function WeekOfTheYear(const AValue: TDateTime; var AYear: Word): Word; overload;

//ex) DayOfTheYear(Today) : 오늘일자가 올해의 몇일째인지를 Word형으로 리턴한다.
function DayOfTheYear(const AValue: TDateTime): Word;

//년의 시작일부터 해당일자까지의 시간을 모두 더해서 Word형으로 리턴한다.
function HourOfTheYear(const AValue: TDateTime): Word;

//년의 시작일부터 해당일자까지의 분을 모두 더해서 Word형으로 리턴한다.
function MinuteOfTheYear(const AValue: TDateTime): LongWord;

//년의 시작일부터 해당일자까지의 초을 모두 더해서 Word형으로 리턴한다.
function SecondOfTheYear(const AValue: TDateTime): LongWord;

//년의 시작일부터 해당일자까지의 밀리초을 모두 더해서 Word형으로 리턴한다.
function MilliSecondOfTheYear(const AValue: TDateTime): Int64;

//이달의 몇번째주 인지를 리턴한다.
function WeekOfTheMonth(const AValue: TDateTime): Word; overload;
function WeekOfTheMonth(const AValue: TDateTime; var AYear, AMonth: Word): Word; overload;

//이달의 몇일째인지를 리턴한다.
function DayOfTheMonth(const AValue: TDateTime): Word;

//월의 시작일부터 해당일자까지의 시간의 합을 리턴한다.
function HourOfTheMonth(const AValue: TDateTime): Word;

//월의 시작일부터 해당일자까지의 분의 합을 리턴한다.
function MinuteOfTheMonth(const AValue: TDateTime): Word;

//월의 시작일부터 해당일자까지의 초의 합을 리턴한다.
function SecondOfTheMonth(const AValue: TDateTime): LongWord;

//월의 시작일부터 해당일자까지의 밀리초의 합을 리턴한다.
function MilliSecondOfTheMonth(const AValue: TDateTime): LongWord;

//해당일의 요일을 리턴한다.
//1:월요일, 2:화요일, 3:수요일, 4:목요일 ,5:금요일 , 6:토요일 ,7:일요일
function DayOfTheWeek(const AValue: TDateTime): Word;

//AValue날짜의 주의 시작일부터 AValue날짜까지의 시간의 합을 계산한다.
function HourOfTheWeek(const AValue: TDateTime): Word;

//AValue날짜의 주의 시작일부터 AValue날짜까지의 분의 합을 계산한다.
function MinuteOfTheWeek(const AValue: TDateTime): Word;

//AValue날짜의 주의 시작일부터 AValue날짜까지의 초의 합을 계산한다.
function SecondOfTheWeek(const AValue: TDateTime): LongWord;

//AValue날짜의 주의 시작일부터 AValue날짜까지의 밀리초의 합을 계산한다.
function MilliSecondOfTheWeek(const AValue: TDateTime): LongWord;

//ex) HourOfTheDay(Time) : 24시간 단위로 Time까지의 시간의 합을 계산한다.
function HourOfTheDay(const AValue: TDateTime): Word;

//ex) MinuteOfTheDay(Time) : 24시간 단위로 Time까지의 분의 합을 계산한다.
function MinuteOfTheDay(const AValue: TDateTime): Word;

//ex) SecondOfTheDay(Time) : 24시간 단위로 Time까지의 초의 합을 계산한다.
function SecondOfTheDay(const AValue: TDateTime): LongWord;

//ex) MilliSecondOfTheDay(Time) : 24시간 단위로 Time까지의 밀리초의 합을 계산한다.
function MilliSecondOfTheDay(const AValue: TDateTime): LongWord;

//ex) MinuteOfTheHour(13:28:43:345) : 시간을 기준으로 분의 합을계산한다.
function MinuteOfTheHour(const AValue: TDateTime): Word;

//ex) SecondOfTheHour(13:28:43:345) : 시간을 기준으로 초의 합을계산한다.
function SecondOfTheHour(const AValue: TDateTime): Word;

//ex) MilliSecondOfTheHour(13:28:43:345) : 시간을 기준으로 밀리초의 합을계산한다.
function MilliSecondOfTheHour(const AValue: TDateTime): LongWord;

//ex) SecondOfTheMinute(13:28:43:345) : 분을 기준으로 초의 합을 계산한다.
function SecondOfTheMinute(const AValue: TDateTime): Word;

//ex) SecondOfTheMinute(13:28:43:345) : 초을 기준으로 밀리초의 합을 계산한다.
function MilliSecondOfTheMinute(const AValue: TDateTime): LongWord;
function MilliSecondOfTheSecond(const AValue: TDateTime): Word;


//두날짜(시간) 사이에 년수를 리턴한다.
function YearsBetween(const ANow, AThen: TDateTime): Integer;

//두날짜(시간) 사이의 월수를 리턴한다.
function MonthsBetween(const ANow, AThen: TDateTime): Integer;

//두날짜(시간) 사이의 주수를 리턴한다.
function WeeksBetween(const ANow, AThen: TDateTime): Integer;

//두날짜(시간) 사이의 일수를 리턴한다.
function DaysBetween(const ANow, AThen: TDateTime): Integer;

//두날짜(시간) 사이의 시간을 리턴한다.
function HoursBetween(const ANow, AThen: TDateTime): Int64;

//두날자(시간) 사이의 분을 리턴한다.
function MinutesBetween(const ANow, AThen: TDateTime): Int64;

//두날짜(시간) 사이의 초를 리턴한다.
function SecondsBetween(const ANow, AThen: TDateTime): Int64;

//두날짜(시간) 사이의 밀리초를 리턴한다.
function MilliSecondsBetween(const ANow, AThen: TDateTime): Int64;



function YearSpan(const ANow, AThen: TDateTime): Double;
function MonthSpan(const ANow, AThen: TDateTime): Double;
function WeekSpan(const ANow, AThen: TDateTime): Double;
function DaySpan(const ANow, AThen: TDateTime): Double;
function HourSpan(const ANow, AThen: TDateTime): Double;
function MinuteSpan(const ANow, AThen: TDateTime): Double;
function SecondSpan(const ANow, AThen: TDateTime): Double;
function MilliSecondSpan(const ANow, AThen: TDateTime): Double;


//AValue일자에서 ANumberOfYears만큼의 년도를 증가한다.
function IncYear(const AValue: TDateTime; const ANumberOfYears: Integer = 1): TDateTime;

//AValue일자에서 ANumberOfWeeks만큼의 주를 증가한다.
function IncWeek(const AValue: TDateTime; const ANumberOfWeeks: Integer = 1): TDateTime;

//AValue일자에서 ANumberOfDays만큼의 일를 증가한다.
function IncDay(const AValue: TDateTime; const ANumberOfDays: Integer = 1): TDateTime;

//AValue일자(시간)에서 ANumberOfHours만큼의 시간를 증가한다.
function IncHour(const AValue: TDateTime; const ANumberOfHours: Int64 = 1): TDateTime;

//AValue일자(시간)에서 ANumberOfMinutes만큼의 분를 증가한다.
function IncMinute(const AValue: TDateTime; const ANumberOfMinutes: Int64 = 1): TDateTime;

//AValue일자(시간)에서 ANumberOfSeconds만큼의 초를 증가한다.
function IncSecond(const AValue: TDateTime; const ANumberOfSeconds: Int64 = 1): TDateTime;

//AValue일자(시간)에서 ANumberOfMilliSeconds만큼의 밀리초를 증가한다.
function IncMilliSecond(const AValue: TDateTime; const ANumberOfMilliSeconds: Int64 = 1): TDateTime;

//년,월,일,시,분,초,밀리초 ---> 날짜(시간)형으로 리턴한다.
function EncodeDateTime(const AYear, AMonth, ADay, AHour, AMinute, ASecond, AMilliSecond: Word): TDateTime;

//날짜(시간)형 ---> 년,월,일,시,분,초,밀리초 Word형으로 리턴한다.
procedure DecodeDateTime(const AValue: TDateTime; out AYear, AMonth, ADay, AHour, AMinute, ASecond, AMilliSecond: Word);

//ex) EncodeDateWeek(2006,25,2) : 2006년 25주차의 첫번째 화요일의 날자를 리턴한다.
function EncodeDateWeek(const AYear, AWeekOfYear: Word; const ADayOfWeek: Word = 1): TDateTime;

//ex) DecodeDateWeek(Today) : 오늘은 몇년 몇째주의 무슨요일인지를 리턴한다.
procedure DecodeDateWeek(const AValue: TDateTime; out AYear, AWeekOfYear, ADayOfWeek: Word);

//AYear년의 ADayOfYear번째일이 며칠인지 리턴한다.
function EncodeDateDay(const AYear, ADayOfYear: Word): TDateTime;

//AValue일자가 몇년의 몇일째인지를 구한다.
procedure DecodeDateDay(const AValue: TDateTime; out AYear, ADayOfYear: Word);

//년,월,월의몇주차,화요일 의 날짜를 리턴한다.
function EncodeDateMonthWeek(const AYear, AMonth, AWeekOfMonth, ADayOfWeek: Word): TDateTime;

//AValue의 년,월,월의몇주차, 요일 구한다.
procedure DecodeDateMonthWeek(const AValue: TDateTime; out AYear, AMonth, AWeekOfMonth, ADayOfWeek: Word);

//년,월,일,시,분,초,밀리초의 유효성을 체크하고 날짜를 구한다.
function TryEncodeDateTime(const AYear, AMonth, ADay, AHour, AMinute, ASecond, AMilliSecond: Word; out AValue: TDateTime): Boolean;

//AYear년의 AWeekOfYear주에 ADayOfWeek요일에 유효성을 체크하고 날짜를 리턴한다.
function TryEncodeDateWeek(const AYear, AWeekOfYear: Word; out AValue: TDateTime; const ADayOfWeek: Word = 1): Boolean;

//AYear년의 ADayOfYear번째날에 유효성을 체크하고 날짜를 구한다.
function TryEncodeDateDay(const AYear, ADayOfYear: Word; out AValue: TDateTime): Boolean;

//AYear(년) AMonth(월) AWeekOfMonth(월의주차) ADayOfWeek(요일) 유효성을 체크하고 날짜를 구한다.
function TryEncodeDateMonthWeek(const AYear, AMonth, AWeekOfMonth, ADayOfWeek: Word; var AValue: TDateTime): Boolean;

//A.날짜(시간) B.날짜(시간) 을 비교한다. A=B(0) , A>B(1) , Afunction CompareDateTime(const A, B: TDateTime): TValueRelationship;
function CompareDate(const A, B: TDateTime): TValueRelationship;
function CompareTime(const A, B: TDateTime): TValueRelationship;


//A.날짜(시간) B.날짜(시간) 을 비교한다
function SameDateTime(const A, B: TDateTime): Boolean;
function SameDate(const A, B: TDateTime): Boolean;
function SameTime(const A, B: TDateTime): Boolean;

//오늘이 이달의 몇번째주인지 리턴한다.
function NthDayOfWeek(const AValue: TDateTime): Word;

//AValue날이 몇년,몇월,월의몇번째주,무슨요일 인지를 구한다.
procedure DecodeDayOfWeekInMonth(const AValue: TDateTime; out AYear, AMonth, ANthDayOfWeek, ADayOfWeek: Word);

//AYear(년), AMonth(월), ANthDayOfWeek(월의몇번째주), ADayOfWeek(요일) ----> 해당일자를 리턴한다.
function EncodeDayOfWeekInMonth(const AYear, AMonth, ANthDayOfWeek, ADayOfWeek: Word): TDateTime;

//AYear(년), AMonth(월), ANthDayOfWeek(월의몇번째주), ADayOfWeek(요일) 의 유효성을 체크하고 날짜를 구한다.
function TryEncodeDayOfWeekInMonth(const AYear, AMonth, ANthDayOfWeek, ADayOfWeek: Word; out AValue: TDateTime): Boolean;


procedure InvalidDateTimeError(const AYear, AMonth, ADay, AHour, AMinute, ASecond, AMilliSecond: Word; const ABaseDate: TDateTime = 0);
procedure InvalidDateWeekError(const AYear, AWeekOfYear, ADayOfWeek: Word);
procedure InvalidDateDayError(const AYear, ADayOfYear: Word);
procedure InvalidDateMonthWeekError(const AYear, AMonth, AWeekOfMonth, ADayOfWeek: Word);
procedure InvalidDayOfWeekInMonthError(const AYear, AMonth, ANthDayOfWeek, ADayOfWeek: Word);


//날짜를 Double형으로 리턴한다.
//0001년01월01일 ---> 1721425
function DateTimeToJulianDate(const AValue: TDateTime): Double;

//Double형을 날짜로 리턴한다.
//1721425 ---> 0001년01월01일
function JulianDateToDateTime(const AValue: Double): TDateTime;

//AValue의 유효성을 체크하고 날짜를 리턴한다.
function TryJulianDateToDateTime(const AValue: Double; out ADateTime: TDateTime): Boolean;

//날짜를 Double형으로 리턴한다.
//0001년01월01일 ---> ( -678575 )
function DateTimeToModifiedJulianDate(const AValue: TDateTime): Double;

//Double형을 날짜로 리턴한다.
//( -678575 ) ---> 0001년01월01일
function ModifiedJulianDateToDateTime(const AValue: Double): TDateTime;

//AValue의 유효성을 체크하고 날짜를 리턴한다.
function TryModifiedJulianDateToDateTime(const AValue: Double; out ADateTime: TDateTime): Boolean;

2011년 6월 13일 월요일

Delphi에서 만든 DLL C++에서 사용하기

====================================================== 
Delphi Code 
====================================================== 

library HWPInfoDll; 
{ Important note about DLL memory management: ShareMem must be the
  first unit in your library's USES clause AND your project's (select
  Project-View Source) USES clause if your DLL exports any procedures
or
  functions that pass strings as parameters or function results. This
  applies to all strings passed to and from your DLL--even those that
  are nested in records and classes. ShareMem is the interface unit to
  the BORLNDMM.DLL shared memory manager, which must be deployed along
  with your DLL. To avoid using BORLNDMM.DLL, pass string information
  using PChar or ShortString parameters. } 
uses
  SysUtils,
  Classes,
  HwpInfo in 'xxx.pas'; 
{$E dll} 
{$R *.res} 
exports
  GetHWPInfo Name 'GetHWPInfo@Delphi';
begin 
end. 
unit HwpInfo; 
interface 
xxxx.pas
uses
  SysUtils,
  strUtils,
  Windows,
  Classes; 
  function GetHWPInfo(sFileFullName: PAnsichar):Integer; cdecl; 
  // 리턴값 0 = 몰라, 1= hwp2002, 2 = hwp2004, 3 = hwp2005, 4 = hwp2007
  function ConvertVersionName (sVer: string): integer ; 
implementation 
function GetHWPINfo(sFileFullName: PAnsichar):integer; cdecl; export;
begin
..
..
end; 




======================================================
C++ 코드
======================================================
선언부
#define Import(TYPE) extern "C" __declspec (dllimport) TYPE WINAPI
typedef int  (WINAPI *GetHWPInfo)(char *str); 
사용부
          // Delphi Dll Load
          GetHWPInfo GetHWPInfo1;
          CString sPath;
          char FullPath[255];
          int nHWPKind; 
          GetCurrentDirectory(255,FullPath); 
          sPath.Format("%s",FullPath); 
          sPath = sPath + "\\HWPInfo.dll"; 
          if (FILEEXISTS_S(sPath.GetBuffer(0))) {
            dprintf("HWPInfo.dll Path ok");
          } else {
            dprintf("HWPInfo.dll Path fail!");
          } 
          HMODULE h = LoadLibrary(sPath.GetBuffer(0)); 
          GetHWPInfo1 = (GetHWPInfo)GetProcAddress(h, "GetHWPInfo@Delphi");
          nHWPKind = GetHWPInfo1(PATH.GetBuffer(0));
          dprintf("HWP Kind = %d", nHWPKind); 
          FreeLibrary(h); 

64bit system32 폴더로 엑세스 하기

64비트 운영체제인 경우  아래 2개의 API를 이용 가능하다.

AAA : function(var OldValue: Pointer): BOOL; stdcall;
BBB : function(OldValue: Pointer): BOOL; stdcall;
pTmp : Pointer;

아래와 같이 선언하여 사용사용이 가능하다.
  AAA := GetProcAddress(GetModuleHandle(kernel32), 'Wow64DisableWow64FsRedirection');
  BBB := GetProcAddress(GetModuleHandle(kernel32), 'Wow64RevertWow64FsRedirection');


if AAA(pTmp) then begin
  // 정상적으로 System32폴더의 내용을 가져올수 있음.

end;


if BBB(pTmp) then begin
  // 64bit 윈도우 기본인 syswow64 폴더의 내용을 가져옴

end;