Cheat Engine Forum Index Cheat Engine
The Official Site of Cheat Engine
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


[Delphi] Running application with name "lol.wtf"

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming
View previous topic :: View next topic  
Author Message
h4c0r-BG
Master Cheater
Reputation: 0

Joined: 29 Nov 2006
Posts: 449
Location: The yogurt country

PostPosted: Fri Dec 07, 2007 11:32 am    Post subject: [Delphi] Running application with name "lol.wtf" Reply with quote

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
View user's profile Send private message
Symbol
I'm a spammer
Reputation: 0

Joined: 18 Apr 2007
Posts: 5094
Location: Israel.

PostPosted: Fri Dec 07, 2007 12:46 pm    Post subject: Reply with quote

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
View user's profile Send private message
Devilizer
Master Cheater
Reputation: 0

Joined: 22 Jun 2007
Posts: 451

PostPosted: Fri Dec 07, 2007 1:00 pm    Post subject: Reply with quote

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
View user's profile Send private message
h4c0r-BG
Master Cheater
Reputation: 0

Joined: 29 Nov 2006
Posts: 449
Location: The yogurt country

PostPosted: Fri Dec 07, 2007 1:02 pm    Post subject: Reply with quote

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. Rolling Eyes
But if i save a bat file with the line:

Code:
start project1.lol


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
View user's profile Send private message
Devilizer
Master Cheater
Reputation: 0

Joined: 22 Jun 2007
Posts: 451

PostPosted: Fri Dec 07, 2007 1:56 pm    Post subject: Reply with quote

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
View user's profile Send private message
Flyte
Peanuts!!!!
Reputation: 6

Joined: 19 Apr 2006
Posts: 1887
Location: Canada

PostPosted: Fri Dec 07, 2007 3:37 pm    Post subject: Reply with quote

You should be able to use CreateProcess();
Back to top
View user's profile Send private message
dnsi0
I post too much
Reputation: 0

Joined: 04 Jan 2007
Posts: 2674

PostPosted: Fri Dec 07, 2007 4:06 pm    Post subject: Reply with quote

lol in VB I can execute the GG file with Shell("GameGuard.des")
Back to top
View user's profile Send private message
Devilizer
Master Cheater
Reputation: 0

Joined: 22 Jun 2007
Posts: 451

PostPosted: Fri Dec 07, 2007 4:40 pm    Post subject: Reply with quote

dnsi0 wrote:
lol in VB I can execute the GG file with Shell("GameGuard.des")

SERIOUSLY?!!

Let me try now -.-
Back to top
View user's profile Send private message
DeletedUser14087
I post too much
Reputation: 2

Joined: 21 Jun 2006
Posts: 3069

PostPosted: Fri Dec 07, 2007 4:49 pm    Post subject: Reply with quote

Flyte wrote:
You should be able to use CreateProcess();
Back to top
View user's profile Send private message
h4c0r-BG
Master Cheater
Reputation: 0

Joined: 29 Nov 2006
Posts: 449
Location: The yogurt country

PostPosted: Sat Dec 08, 2007 9:34 am    Post subject: Reply with quote

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
View user's profile Send private message
atom0s
Moderator
Reputation: 205

Joined: 25 Jan 2006
Posts: 8587
Location: 127.0.0.1

PostPosted: Sat Dec 08, 2007 12:19 pm    Post subject: Reply with quote

Should give credit to the person that wrote the code. Wink

http://www.swissdelphicenter.ch/en/showcode.php?id=93

_________________
- Retired.
Back to top
View user's profile Send private message Visit poster's website
sponge
I'm a spammer
Reputation: 1

Joined: 07 Nov 2006
Posts: 6009

PostPosted: Sat Dec 08, 2007 1:46 pm    Post subject: Reply with quote

CreateProcess is easier... like everyone else said.
_________________
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group

CE Wiki   IRC (#CEF)   Twitter
Third party websites