Skip to content

Commit

Permalink
runasadmin use widechar
Browse files Browse the repository at this point in the history
  • Loading branch information
riderkick committed Jun 10, 2015
1 parent 7da5d21 commit f3d2c34
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 30 deletions.
55 changes: 29 additions & 26 deletions baseunits/uBaseUnit.pas
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,17 @@

unit uBaseUnit;

{$MODE DELPHI}
{$mode objfpc}{$H+}
{$MACRO ON}
{$DEFINE DOWNLOADER}

interface

uses
SysUtils, Classes, Graphics, Forms, UTF8Process, strutils, fileinfo, process,
fpjson, jsonparser, FastHTMLParser, fgl, uFMDThread, synautil, httpsend,
blcksock, ssl_openssl, GZIPUtils, USimpleException, USimpleLogger;
SysUtils, Classes, Graphics, Forms, UTF8Process, lazutf8classes,
LazUTF8, strutils, fileinfo, process, fpjson, jsonparser, FastHTMLParser, fgl,
uFMDThread, synautil, httpsend, blcksock, ssl_openssl, GZIPUtils,
USimpleException, USimpleLogger;

const
FMD_REVISION = '$WCREV$';
Expand Down Expand Up @@ -773,8 +774,8 @@ TFavoriteInfo = record
Checking: Boolean;
end;

TCardinalList = TFPGList<Cardinal>;
TByteList = TFPGList<Byte>;
TCardinalList = specialize TFPGList<Cardinal>;
TByteList = specialize TFPGList<Byte>;

TDownloadPageThread = class(TThread)
protected
Expand Down Expand Up @@ -965,7 +966,7 @@ implementation
{$ifdef UNIX}Process,{$endif UNIX}
{$IFDEF WINDOWS}ShellApi, RegExpr, Windows,{$ENDIF}
{$IFDEF DOWNLOADER}frmMain,{$ENDIF}
FileUtil, lazutf8classes, uMisc;
FileUtil, uMisc;

{$IFDEF WINDOWS}
// thanks Leledumbo for the code
Expand Down Expand Up @@ -3426,8 +3427,8 @@ function TParseHTML.Exec(const Raw: string): string;
Output.Clear;
parser := THTMLParser.Create(PChar(FRaw));
try
parser.OnFoundTag := FoundTag;
parser.OnFoundText := FoundText;
parser.OnFoundTag := @FoundTag;
parser.OnFoundText := @FoundText;
parser.Exec;
finally
parser.Free;
Expand Down Expand Up @@ -3520,30 +3521,32 @@ function RunExternalProcessAsAdmin(Exe, Params: String; ShowWind: Boolean;
isPersistent: Boolean): Boolean;
var
{$IFDEF WINDOWS}
sei: TShellExecuteInfoA;
SEInfo: TSHELLEXECUTEINFOW;
{$ELSE}
Process: TProcessUTF8;
pr: TStringList;
{$ENDIF}
begin
{$IFDEF WINDOWS}
Initialize(sei);
FillChar(sei, SizeOf(sei), 0);
sei.cbSize := SizeOf(sei);
sei.wnd := 0;
sei.fMask := SEE_MASK_FLAG_DDEWAIT or SEE_MASK_FLAG_NO_UI;
if isPersistent then
sei.fMask := sei.fMask or SEE_MASK_NOCLOSEPROCESS;
sei.lpVerb := 'runas';
sei.lpFile := PChar(Exe);
sei.lpParameters := PChar(Params);
if ShowWind then
sei.nShow := SW_SHOWNORMAL
else
sei.nShow := SW_HIDE;
Result := ShellExecuteExA(@sei);
Initialize(SEInfo);
FillChar(SEInfo, SizeOf(SEInfo), 0);
SEInfo.cbSize := SizeOf(SEInfo);
with SEInfo do begin
wnd := 0;
fMask := SEE_MASK_FLAG_DDEWAIT or SEE_MASK_FLAG_NO_UI;
if isPersistent then
fMask := fMask or SEE_MASK_NOCLOSEPROCESS;
lpVerb := 'runas';
lpFile := PWideChar(WideString(UTF8ToSys(Exe)));
lpParameters := PWideChar(WideString(UTF8ToSys(Params)));
if ShowWind then
nShow := SW_SHOWNORMAL
else
nShow := SW_HIDE;
end;
Result := ShellExecuteExW(@SEInfo);
if isPersistent then
WaitForSingleObject(sei.hProcess, INFINITE);
WaitForSingleObject(SEInfo.hProcess, INFINITE);
{$ELSE}
Process := TProcessUTF8.Create(nil);
try
Expand Down
5 changes: 1 addition & 4 deletions mangadownloader/forms/frmMain.pas
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,7 @@

unit frmMain;

{$ifdef fpc}
{$mode objfpc}
{$endif}
{$H+}
{$mode objfpc}{$H+}

interface

Expand Down

0 comments on commit f3d2c34

Please sign in to comment.