본문 바로가기

운동하는 개발자/Delphi

(16)
Delphi 2010 Indy 업그레이드 (재설치) 회사에서 Delphi 2010 버전을 사용하고 있는데 이는 설치하면 과거버전의 Indy가 설치되어 있어서 특정 기능들을 사용할 수 없다. 그래서 최신 Indy로 교체시켜줘야 한다 1. 최신 Indy 다운로드 https://www.indyproject.org/ 여기서 다운로드 가능하며 현재는 github로 연동해놨다 (https://github.com/IndySockets/Indy) GitHub - IndySockets/Indy: Indy - Internet Direct Indy - Internet Direct. Contribute to IndySockets/Indy development by creating an account on GitHub. github.com 2. 기존 Indy 삭제 1) Delp..
델파이 프로세스 실행 + 종료 기다리기 / Delphi Create Process and wait for close process 델파이에서 외부 프로그램을 실행시키고 그 프로그램이 종료대기까지 기다려야 하는 경우 사용법 (예: github에서 그렇듯 commit메세지를 입력받기 위해 메모장을 띄우고 해당 메모장 프로그램이 종료되길 기다리는 경우) string lExePath //프로그램 풀 경로 c:\work\notepad.exe lExePath := Trim(lExePath); //정확한 이유는 모르겠지만 공백이 없더라도 이 작업이 필수 if CreateProcess(nil, PWideChar(lExePath), nil, nil, False, 0, nil, nil, StartupInfo, ProcessInfo) then begin //정상적으로 실행했을경우 with ProcessInfo do begin WaitForSingleO..
델파이 한글검색, 검색기록 관리 편하게 GEXPERT 설치 델파이 2010버전을 쓰면서 같은 프로젝트 내의 pas파일인데 간헐적으로 한글이 검색되지 않는 문제가 있었습니다 (해당 파일을 열어줘야 검색이 됨) 방법을 찾다가 GExperts의 검색기능을 쓰면 된다고 하여 써보고 한글검색 뿐만아니라 편의성 기능이 많아 소개합니다 https://www.gexperts.org/download/ Download | GExperts Download GExperts GExperts is provided to developers free of charge in both source code and binary format. Before downloading, you must read and agree to the license agreement. GExperts is 100% ..
델파이 크리티컬세션 사용법 / delphi criticalsection (for multiThread) 멀티스레드의 환경을 개발하는 경우 여러 쓰레드가 같은 파일에 접근하거나 상태 값, 인덱스 값 등을 갱신/읽기 하려는 경우가 많이 있다 이때 자칫하다간 원하는 대로 동작하지 않거나 access violation이 발생하기도 한다 이를 방지하기 위해 동시에 접근하는 메모리,변수 등에 크리티컬섹션을 걸어서 충돌을 방지하자 선언부 uses windows; var CriticalSection: TRTLCriticalSection; ~~~~~~~~~ ~~class~~ ~~~~~~~~~ initialization InitializeCriticalSection(CriticalSection); finalization DeleteCriticalSection(CriticalSection); 사용부분 workSum : Int..
델파이 windows10 한글 깨짐 / edit 창 한글 커서 오류 (d2codingfont) ● 발생 환경 - 델파이 2010, XE5 - 윈도우7에서는 문제없으나 윈도우10으로 사용시 문제 발생 ● 현상 위와 같이 문자열을 한글로 입력시 커서가 딴데 있을때는 정상적으로 표출됨 위와같이 커서가 해당 라인에 들어가면 커서의 위치와 괄호의 위치가 비정상적으로 표시 TMI 더보기 괄호의 위치로 추측하건데 한글도 똑같이 1바이트로 계산하여 괄도 닫는곳이 한글 글자수x칸 만큼 앞으로 당겨져 보였다 ● 문제해결 결과적으로 기본 폰트의 오류 였다 Tools-> Options 를 들어가서 Editor Options->Display탭에서 Editor font를 보면 디폴트로 Courier New가 설정되어있는데 이를 변경시켜주면 된다 나는 네이버의 D2Coding폰트가 가독성이 좋다 하여 해당폰트를 다운받았다 ..
delphi 각종 윈도우 경로 읽기 get windows path / SHGetSpecialFolderPath uses shlObj; SHGetSpecialFolderPath([핸들], [리턴받을 경로], [찾을 폴더명], [생성여부] 이 함수에서 찾을 폴더명(CSIDL)을 아래 링크를 참조하여 찾아보면 된다 사용 예시) function GetWindowsPath(nCSIDL): String; var P: array [0..MAX_PATH] of Char; begin if SHGetSpecialFolderPath(0, @P[0], nCSIDL, True) then Result := P else Result := ''; end; sAppdataPath := GetWindowsPath(CSIDL_APPDATA); sProgramPath := GetWindowsPath(CSIDL_PROGRAM_FILES); 위와같이 ..
델파이 DBXJSON를 이용한 json 생성 / how to make json at delphi (DBXJSON) 델파이2010에선 JSON unit이 없어서 DBXJSON을 사용하여 json을 생성하는 방법입니다 uses DBXJSON; function makejson():string; var JTopObj, JObj : TJSONObject; JArr : TJSONArray; JPair : TJSONPair; i : integer; sTemp : String; begin JTopObj := TJSONObject.Create; JArr := TJSONArray.Create; for i := 1 to 3 do begin JObj := TJSONObject.Create; JObj.AddPair(TJSONPair.Create('array_index', TJSONNumber.Create( i ))); JObj.AddPai..
델파이 idhttp 에러메세지 내용 확인 / idhttp error message idhttp로 통신 중 400대 , 500의 응답코드가 올 때 단순히 에러 메세지를 수집하면 400 Bad Request 500 Internal Server Error 이런식으로만 획득 된다 postman으로 전송해보면 에러 메세지가 리턴와서 확인해보니 서버측에서 보내는 에러 메세지를 확인하는 방법이 있으며 코드는 아래와 같다 try sHttpResult := Http.Post(sUrl, tsArguments); except on E:EIdHTTPProtocolException do begin sHttpResult := E.ErrorMessage; //예) 1st parameter error //e.message //예)Bed Request //e.errorcode //예)400 end; end;