View previous topic :: View next topic |
Author |
Message |
h4c0r-BG Master Cheater
Reputation: 0
Joined: 29 Nov 2006 Posts: 449 Location: The yogurt country
|
Posted: Fri Dec 07, 2007 11:32 am Post subject: [Delphi] Running application with name "lol.wtf" |
|
|
I've renamed my application name and extention to "lol.wtf"
I want to make a button on my program and whenever i click it to run my application "lol.wtf" but because it is not "lol.exe" it does not run.
P.P. I am using shellexecute:
Code: | ShellExecute(0, pchar('execute'),pchar('lol.wtf'), pchar(''),pchar(''), SW_NORMAL); |
Can anybody help me how to run it?
_________________
|
|
Back to top |
|
 |
Symbol I'm a spammer
Reputation: 0
Joined: 18 Apr 2007 Posts: 5094 Location: Israel.
|
Posted: Fri Dec 07, 2007 12:46 pm Post subject: |
|
|
If you want to make a new extention (.wtf) you have to write to to HKEY_CLASSES_ROOT, make a new key and the value will be the program it will be opened with. (Lets say, .CT will be opened with Cheat Engine 5.3)
|
|
Back to top |
|
 |
Devilizer Master Cheater
Reputation: 0
Joined: 22 Jun 2007 Posts: 451
|
Posted: Fri Dec 07, 2007 1:00 pm Post subject: |
|
|
Not sure about delphi, but if someone can convert vb codes into delphi, here goes.
Code: |
Private Declare Sub SHChangeNotify Lib "shell32.dll" (ByVal wEventId As Long, _
ByVal uFlags As Long, ByVal dwItem1 As Long, ByVal dwItem2 As Long)
Const SHCNE_ASSOCCHANGED = &H8000000
Const SHCNF_IDLIST = 0
Sub CreateFileAssociation(ByVal Extension As String, ByVal ClassName As String, _
ByVal Description As String, ByVal ExeProgram As String)
Const HKEY_CLASSES_ROOT = &H80000000
End Sub
|
|
|
Back to top |
|
 |
h4c0r-BG Master Cheater
Reputation: 0
Joined: 29 Nov 2006 Posts: 449 Location: The yogurt country
|
Posted: Fri Dec 07, 2007 1:02 pm Post subject: |
|
|
No applications can be run without nothing. I don't want association of the file.
Okay i will give another example:
I have project1.exe
I have renamed it to project1.lol
With double click it can't be started .... everybody knows i hope.
But if i save a bat file with the line:
whenever i run that *.bat file the project1.lol will start like it is project1.exe
What i am asking is:
How i can run an application with name "project1.lol" with a simple click of a button?
_________________
|
|
Back to top |
|
 |
Devilizer Master Cheater
Reputation: 0
Joined: 22 Jun 2007 Posts: 451
|
Posted: Fri Dec 07, 2007 1:56 pm Post subject: |
|
|
Ohh, i think i understand what you want now.
Make your own application extension?
Then you'll need to write two keys to HKEY_CLASSES_ROOT.
HKEY_CLASSES_ROOT\.lol\
HKEY_CLASSES_ROOT\.lol\Default = "MyApp.Document"
You then create another key with this name:
HKEY_CLASSES_ROOT\MyApp.Document\
Create a sub-key of this called "shell", a sub-key of *this* called "open" and a further sub-key of "open" called "command".
I think this is it >.<
|
|
Back to top |
|
 |
Flyte Peanuts!!!!
Reputation: 6
Joined: 19 Apr 2006 Posts: 1887 Location: Canada
|
Posted: Fri Dec 07, 2007 3:37 pm Post subject: |
|
|
You should be able to use CreateProcess();
|
|
Back to top |
|
 |
dnsi0 I post too much
Reputation: 0
Joined: 04 Jan 2007 Posts: 2674
|
Posted: Fri Dec 07, 2007 4:06 pm Post subject: |
|
|
lol in VB I can execute the GG file with Shell("GameGuard.des")
|
|
Back to top |
|
 |
Devilizer Master Cheater
Reputation: 0
Joined: 22 Jun 2007 Posts: 451
|
Posted: Fri Dec 07, 2007 4:40 pm Post subject: |
|
|
dnsi0 wrote: | lol in VB I can execute the GG file with Shell("GameGuard.des") |
SERIOUSLY?!!
Let me try now -.-
|
|
Back to top |
|
 |
DeletedUser14087 I post too much
Reputation: 2
Joined: 21 Jun 2006 Posts: 3069
|
Posted: Fri Dec 07, 2007 4:49 pm Post subject: |
|
|
Flyte wrote: | You should be able to use CreateProcess(); |
|
|
Back to top |
|
 |
h4c0r-BG Master Cheater
Reputation: 0
Joined: 29 Nov 2006 Posts: 449 Location: The yogurt country
|
Posted: Sat Dec 08, 2007 9:34 am Post subject: |
|
|
I've completed my task. I found a way. Here it is:
Code: | function WinExecAndWait32V2(FileName: string; Visibility: Integer): DWORD;
procedure WaitFor(processHandle: THandle);
var
Msg: TMsg;
ret: DWORD;
begin
repeat
ret := MsgWaitForMultipleObjects(1, { 1 handle to wait on }
processHandle, { the handle }
False, { wake on any event }
INFINITE, { wait without timeout }
QS_PAINT or { wake on paint messages }
QS_SENDMESSAGE { or messages from other threads }
);
if ret = WAIT_FAILED then Exit; { can do little here }
if ret = (WAIT_OBJECT_0 + 1) then
begin
{ Woke on a message, process paint messages only. Calling
PeekMessage gets messages send from other threads processed. }
while PeekMessage(Msg, 0, WM_PAINT, WM_PAINT, PM_REMOVE) do
DispatchMessage(Msg);
end;
until ret = WAIT_OBJECT_0;
end; { Waitfor }
var { V1 by Pat Ritchey, V2 by P.Below }
zAppName: array[0..512] of char;
StartupInfo: TStartupInfo;
ProcessInfo: TProcessInformation;
begin { WinExecAndWait32V2 }
StrPCopy(zAppName, FileName);
FillChar(StartupInfo, SizeOf(StartupInfo), #0);
StartupInfo.cb := SizeOf(StartupInfo);
StartupInfo.dwFlags := STARTF_USESHOWWINDOW;
StartupInfo.wShowWindow := Visibility;
if not CreateProcess(nil,
zAppName, { pointer to command line string }
nil, { pointer to process security attributes }
nil, { pointer to thread security attributes }
False, { handle inheritance flag }
CREATE_NEW_CONSOLE or { creation flags }
NORMAL_PRIORITY_CLASS,
nil, { pointer to new environment block }
nil, { pointer to current directory name }
StartupInfo, { pointer to STARTUPINFO }
ProcessInfo) { pointer to PROCESS_INF } then
Result := DWORD(-1) { failed, GetLastError has error code }
else
begin
Waitfor(ProcessInfo.hProcess);
GetExitCodeProcess(ProcessInfo.hProcess, Result);
CloseHandle(ProcessInfo.hProcess);
CloseHandle(ProcessInfo.hThread);
end; { Else }
end; { WinExecAndWait32V2 } |
And now at the button simply:
Code: | procedure TForm1.Button1Click(Sender: TObject);
begin
WinExecAndWait32V2('lol.wtf', SW_SHOWNORMAL);
end; |
_________________
|
|
Back to top |
|
 |
atom0s Moderator
Reputation: 205
Joined: 25 Jan 2006 Posts: 8587 Location: 127.0.0.1
|
|
Back to top |
|
 |
sponge I'm a spammer
Reputation: 1
Joined: 07 Nov 2006 Posts: 6009
|
Posted: Sat Dec 08, 2007 1:46 pm Post subject: |
|
|
CreateProcess is easier... like everyone else said.
_________________
|
|
Back to top |
|
 |
|