wonder is any way to prevent user access that file but app can access that file
We do not know much about your "target.exe" file, maybe you can feed it with your configuration via a CLI pipe "<" or call that "target.exe" direct with your settings ... ?
AFAIK there is no way to prevent, when it is physical than it is exposed, no matter what.
Within your own application there are possibilities (but also such can be overridden, depend on how much a user is willing to spend time) but for 3rd party not.
some guy in visulneo forum give me a hint in delphi . can i send here to see whats he did ? maybe help to convert that in pascal
as i review that hint i think its an other Wait For Exit Thing . will Sent Maybe you Better Undrestand That
This is What exactly he say :
```
Perhaps these hints will help:
procedure TForm1.Button1Click(Sender: TObject);
var HW:hwnd;
begin
ShellExecute(Handle,'open','C:\windows\notepad.exe',nil,nil,SW_SHOW); //run notepad
sleep(100); //sleep, or there won't be a window handel
hw:== FindWindow(vbNullString, "Calculator") // find the handle of the desired window (Use vbNullString to ignore the window class)
Windows.SetParent(hw,Handle); //make it a child window of your application
end;
***
The example shows how to start an external application from your program and wait for it to complete.
function ExecAndWait(const FileName,
Params: ShortString;
const WinState: Word): boolean; export;
var
StartInfo: TStartupInfo;
ProcInfo: TProcessInformation;
CmdLine: ShortString;
begin
{ Put the file name between quotation marks, respecting all spaces in Win9x names }
CmdLine := '"' + Filename + '" ' + Params;
FillChar(StartInfo, SizeOf(StartInfo), #0);
with StartInfo do
begin
cb := SizeOf(SUInfo);
dwFlags := STARTF_USESHOWWINDOW;
wShowWindow := WinState;
end;
Result := CreateProcess(nil, PChar( String( CmdLine ) ), nil, nil, false,
CREATE_NEW_CONSOLE or NORMAL_PRIORITY_CLASS, nil,
PChar(ExtractFilePath(Filename)),StartInfo,ProcInfo);
{ Waiting for the application to complete }
if Result then
begin
WaitForSingleObject(ProcInfo.hProcess, INFINITE);
{ Free the Handles }
CloseHandle(ProcInfo.hProcess);
CloseHandle(ProcInfo.hThread);
end;
end;
And here is an example of calling this function:
ExecAndWait( 'C:\windows\calc.exe', '', SH_SHOWNORMAL)
Parameter FileName =Name of the external program.
Parameter Params = Parameters required to run an external program
Parameter WinState = Specifies how the window will be displayed:
We can also use the following constants for this parameter: SW_HIDE, SW_MAXIMIZE, SW_MINIMIZE, SW_SHOWNORMAL
PS: This code was tested in delphi versions 3, 4 and 5.
It works in 7 just needs to be replaced:
cb := SizeOf(SUInfo);
на
cb := SizeOf(StartInfo);
***
The example shows how to start an external application from your program and wait for it to complete.
01
function ExecAndWait(const FileName,
02
Params: ShortString;
03
const WinState: Word): boolean; export;
04
var
05
StartInfo: TStartupInfo;
06
ProcInfo: TProcessInformation;
07
CmdLine: ShortString;
08
begin
09
{ Put the file name between quotation marks, respecting all spaces in Win9x names }
10
CmdLine := '"' + Filename + '" ' + Params;
11
FillChar(StartInfo, SizeOf(StartInfo), #0);
12
with StartInfo do
13
begin
14
cb := SizeOf(SUInfo);
15
dwFlags := STARTF_USESHOWWINDOW;
16
wShowWindow := WinState;
17
end;
18
Result := CreateProcess(nil, PChar( String( CmdLine ) ), nil, nil, false,
19
CREATE_NEW_CONSOLE or NORMAL_PRIORITY_CLASS, nil,
20
PChar(ExtractFilePath(Filename)),StartInfo,ProcInfo);
21
{ Waiting for the application to complete }
22
if Result then
23
begin
24
WaitForSingleObject(ProcInfo.hProcess, INFINITE);
25
{ Free the Handles }
26
CloseHandle(ProcInfo.hProcess);
27
CloseHandle(ProcInfo.hThread);
28
end;
29
end;
And here is an example of calling this function:
1
ExecAndWait( 'C:windowscalc.exe', '', SH_SHOWNORMAL)
Parameter FileName = Name of the external program. Parameter Params = Parameters required to run an external program. Parameter WinState = Specifies how the window will be displayed: For this parameter we can also use the following constants: SW_HIDE, SW_MAXIMIZE, SW_MINIMIZE, SW_SHOWNORMAL
```