본문 바로가기

삽질/Delphi40

[Delphi] InnoSetup : 방화벽 추가 (netsh.exe) # WIN 7 이상 [Run] Filename: {sys}\netsh.exe; Parameters: "advfirewall firewall add rule name=""MyApp"" protocol=TCP dir=in program=""{app}\MyApp.exe"" action=allow localport=""8100,443"""; StatusMsg: "MyApp"; Flags: runhidden [UninstallRun] Filename: {sys}\netsh.exe; Parameters: "advfirewall firewall delete rule name=""MyApp"" program=""{app}\MyApp.exe"""; Flags: runhidden # WIN XP 이하 [Run] Filen.. 2021. 8. 30.
[Delphi] 프로그램 활성화하기 // --------------------------------------------// 파일이 실행상태가 아니면 실행하기// 최소화 상태면 활성화시키기// 다른 창 아래에 가려졌으면 맨 앞으로 가져오기// --------------------------------------------procedure test;begin h := WindowFromProcessID(getProcessId('실행파일명.exe')); // h := FindWindow('TFormName', nil); if h = 0 then ShellExecute(handle, 'open', PChar(FileName), nil, nil, SW_SHOW) else if IsIconic(h) then ShowWindow(h, SW_RESTO.. 2020. 8. 7.
[Delphi] ComPort 오류 수정 // 델파이 xe 등에서 한글 깨질때 string -> AnsiString 변경 function WriteStr(Str: AnsiString): Integer; function WriteStrAsync(var Str: AnsiString; var AsyncPtr: PAsync): Integer; // INFINITE는 작업 종료까지 무한대 기다리기 때문에 수정 function TCustomComPort.WaitForAsync(var AsyncPtr: PAsync): Integer; // Signaled := WaitForSingleObject(AsyncPtr^.Overlapped.hEvent, INFINITE); Signaled := WaitForSingleObject(AsyncPtr^.Overlappe.. 2020. 8. 3.
[Delphi] 기본 프린터 설정 및 정보 가져오기 type TPrinterInfo = record SeverName: PChar; PrinterName: PChar; ShareName: PChar; PortName: PChar; DriverName: PChar; Comment: PChar; Location: PChar; DeviceMode: PDeviceModeW; SepFile: PChar; PrintProcessor: PChar; DataType: PChar; Parameters: PChar; SecurityDescriptor: PSecurityDescriptor; Attributes: Cardinal; DefaultPriority: Cardinal; StartTime: Cardinal; UntilTime: Cardinal; Status: Cardi.. 2020. 5. 28.
[Delphi] TStringlist를 OleVariant로 변환하기 function StreamToVariant(Stream: TStream): OleVariant; var p: Pointer; begin Result := VarArrayCreate([0, Stream.Size - 1], varByte); p := VarArrayLock(Result); try Stream.Position := 0; Stream.Read(p^, Stream.Size); finally VarArrayUnlock(Result); end; end; function StringlistToVariant(aStrlist: TStrings): OleVariant; var hStream: TStream; begin hStream := TMemoryStream.Create; try aStrlist.Sav.. 2019. 6. 14.
[Delphi] Webbrowser html 가져오기 방법1) WB.OleObject.Document.documentElement.outerHTML; 방법2) function GetHTML: String; Var E: IHTMLElement; begin result := ''; if Assigned(WB.Document) then begin E := (WB.Document as IHTMLDocument2).body; while E.parentElement nil do begin E := E.parentElement; end; result := E.outerHTML; end; end; 2019. 6. 14.
[Delphi] 중국어 번체<->간체 function StrConv(const sText: String; Conversion: DWORD): String; overload; var nSize: Integer; begin nSize := LCMapString(LOCALE_SYSTEM_DEFAULT, Conversion, PChar(sText), Length(sText), nil, 0); SetLength(Result, nSize); nSize := LCMapString(LOCALE_SYSTEM_DEFAULT, Conversion, PChar(sText), Length(sText), PChar(Result), nSize); if nSize 2019. 6. 14.
[Delphi] 듀얼모니터에 폼 띄우기 Form1 := TForm1.Create(nil);Form1.Top := screen.monitors[0].Top;Form1.Left := screen.monitors[0].Left;Form1.DefaultMonitor := dmDesktop; // 이거 못찾아서 삽질 한참했네 ㅠㅠForm1.Show; 그냥 Left값 지정한다고 되는게 아니라 dmDesktop 이거 해줘야 함! 2018. 1. 9.
[Delphi] InnoSetup : 설치 시 압축파일 풀기 [Files]Source: unzip.exe; DestDir: {userappdata}\testFolder; AfterInstall: UnzipSource: testFile.zip; DestDir: {userappdata}\testFolder [Code]procedure Unzip;var path: string; ResultCode: Integer;begin path := ExpandConstant('{userappdata}') + '\testFolder\' Exec(path + 'unzip.exe', '-u ' + path + 'testFile.zip', '', SW_HIDE, ewWaitUntilTerminated, ResultCode); end; 2017. 10. 2.
[Delphi] InnoSetup : 설치 시 강제로 프로세스 죽이기 [Files]Source: "progtest.exe"; DestDir: "{app}"; BeforeInstall: TaskKill(progtest.exe) [Code]procedure TaskKill(FileName: String);var ResultCode: Integer;begin Exec(ExpandConstant('taskkill.exe'), '/f /im ' + '"' + FileName + '"', '', SW_HIDE, ewWaitUntilTerminated, ResultCode); end; 2017. 10. 2.