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 


Open With help
Goto page 1, 2  Next
 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming
View previous topic :: View next topic  
Author Message
HomerSexual
Grandmaster Cheater Supreme
Reputation: 5

Joined: 03 Feb 2007
Posts: 1657

PostPosted: Sun May 04, 2008 10:17 am    Post subject: Open With help Reply with quote

So i have cPad a few topics down.

How would i make it so i can open a file using openwith from cPad.

example

text.txt on desktop
open with > cPad.exe
File Loads

_________________
Back to top
View user's profile Send private message
Stylo
Grandmaster Cheater Supreme
Reputation: 3

Joined: 16 May 2007
Posts: 1073
Location: Israel

PostPosted: Sun May 04, 2008 11:00 am    Post subject: Reply with quote

when you're in the list of the openwith browse to cPad and double click it Surprised
_________________
Stylo
Back to top
View user's profile Send private message
HomerSexual
Grandmaster Cheater Supreme
Reputation: 5

Joined: 03 Feb 2007
Posts: 1657

PostPosted: Sun May 04, 2008 11:09 am    Post subject: Reply with quote

The problem is that when i do that, cPad opens and no files are there o.o
_________________
Back to top
View user's profile Send private message
Stylo
Grandmaster Cheater Supreme
Reputation: 3

Joined: 16 May 2007
Posts: 1073
Location: Israel

PostPosted: Sun May 04, 2008 11:48 am    Post subject: Reply with quote

well i googled for this and found nothing..
i'm almost sure it's an event that starts with the application's load though

_________________
Stylo
Back to top
View user's profile Send private message
HolyBlah
Master Cheater
Reputation: 2

Joined: 24 Aug 2007
Posts: 446

PostPosted: Sun May 04, 2008 12:18 pm    Post subject: Reply with quote

When you open a file with a program the system send the file path as the first parameter.
Back to top
View user's profile Send private message
HomerSexual
Grandmaster Cheater Supreme
Reputation: 5

Joined: 03 Feb 2007
Posts: 1657

PostPosted: Sun May 04, 2008 12:21 pm    Post subject: Reply with quote

So how would i utilize that, i know it will be in WM_CREATE but whats the checks?

Wiccan, come to the rescue

_________________
Back to top
View user's profile Send private message
tombana
Master Cheater
Reputation: 2

Joined: 14 Jun 2007
Posts: 456
Location: The Netherlands

PostPosted: Sun May 04, 2008 12:48 pm    Post subject: Reply with quote

I think you have to use GetCommandLine for that.
If you code in C++ it's a parameter given to the main() function. (Probably other languages too, I dunno about that)
Back to top
View user's profile Send private message
HomerSexual
Grandmaster Cheater Supreme
Reputation: 5

Joined: 03 Feb 2007
Posts: 1657

PostPosted: Sun May 04, 2008 12:57 pm    Post subject: Reply with quote

I use a win32 gui skeleton so theres no main() and the parameters to my FrameProc can't take that parameter.

My source is te cPad MDI notepad source a few below

_________________
Back to top
View user's profile Send private message
HalfPrime
Grandmaster Cheater
Reputation: 0

Joined: 12 Mar 2008
Posts: 532
Location: Right there...On your monitor

PostPosted: Sun May 04, 2008 1:01 pm    Post subject: Reply with quote

try getstartupinfo?
EDIT:
Code:
int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance,
               PSTR szCmdLine, int iCmdShow)

szCmdLine may contain the extra info.

_________________
Back to top
View user's profile Send private message
Jani
Grandmaster Cheater
Reputation: 2

Joined: 29 Dec 2006
Posts: 804

PostPosted: Sun May 04, 2008 2:04 pm    Post subject: Reply with quote

I'll reply here too, so other people can learn too or something...

And the mighty answer is here: parse the arguments. :P
Back to top
View user's profile Send private message
atom0s
Moderator
Reputation: 205

Joined: 25 Jan 2006
Posts: 8588
Location: 127.0.0.1

PostPosted: Sun May 04, 2008 2:33 pm    Post subject: Reply with quote

Add a shell extension for the application.

Something such as:

HKEY_CLASSES_ROOT\*\shell\cPad\command\

After creating that, you will need to set the default value to the path of your program with %1 at the end meaning the file name/path. So it should look like:

(Default) REG_SZ "C:\Program Files\cPad\cPad.exe" "%1"

You can add the extension for the program to each file type as well if needed for specific file types.

_________________
- Retired.
Back to top
View user's profile Send private message Visit poster's website
HomerSexual
Grandmaster Cheater Supreme
Reputation: 5

Joined: 03 Feb 2007
Posts: 1657

PostPosted: Sun May 04, 2008 2:40 pm    Post subject: Reply with quote

Wiccan, you don't get it. I know how to do that. but it's in my actual app

Code:
   if(strcmp(szCmdLine, "")){
      SendMessage (hwndFrame, WM_COMMAND, IDM_FILE_NEWFILE, 0);
      HWND hEdit = GetDlgItem(hwndChild, IDC_EDIT);
      MessageBox(0, szCmdLine, "error", MB_OK);
      LoadFile(hEdit, "szCmdLine");
   }

I put that in WinMain

szCmdLine is in format C:\temp.txt but CreateProcess needs C:\\temp.txt

So how can i turn a string with \ to a string with \\ in it?

_________________
Back to top
View user's profile Send private message
Jani
Grandmaster Cheater
Reputation: 2

Joined: 29 Dec 2006
Posts: 804

PostPosted: Sun May 04, 2008 2:58 pm    Post subject: Reply with quote

blankrider wrote:
So how can i turn a string with \ to a string with \\ in it?
Still pasting from IRC to others: 23:22:20 < Jani> Start from the back, count the \, allocate more memory, then just move the stuff beginning from the end to right as many times as theres \ left and replace every \ with \\.

Or.. Switch to C++ and use std::string.replace :P
Back to top
View user's profile Send private message
atom0s
Moderator
Reputation: 205

Joined: 25 Jan 2006
Posts: 8588
Location: 127.0.0.1

PostPosted: Sun May 04, 2008 6:07 pm    Post subject: Reply with quote

I'd use std::string myself as well.

As for your issue, I don't know if you can fix the path since if the path is stored using \ in it, it wont show up in memory correctly. Instead, it will fuck the path up and handle it as an escape character. Depending on the next character after it. In your case:

C:\temp.txt would handle \t as a tab character. Which in memory would look like:

"C:emp.txt" Which the tab character is filtered out and stored as the 'tab' hex value which would make the string:

27 43 3A 09 65 6D 70 2E 74 78 74

_________________
- Retired.
Back to top
View user's profile Send private message Visit poster's website
HomerSexual
Grandmaster Cheater Supreme
Reputation: 5

Joined: 03 Feb 2007
Posts: 1657

PostPosted: Sun May 04, 2008 9:15 pm    Post subject: Reply with quote

Code:
   if(strcmp(szCmdLine, "")){
      filename = szCmdLine;
      int position = filename.find( "\\" ); // find first space
      while ( position != std::string.npos )
      {
        filename.replace( position, 1, "\\\\" );
        position = filename.find( "\\", position + 1 );
      }
      char* cstr = new char [filename.size()+1];
      strcpy (cstr, filename.c_str());
      SendMessage (hwndFrame, WM_COMMAND, IDM_FILE_NEWFILE, 0);
      HWND hEdit = GetDlgItem(hwndChild, IDC_EDIT);
      MessageBox(0, cstr, "asdf", MB_OK);
      LoadFile(hEdit, cstr);
   }
   


Now i get a hang on
Code:
 filename.replace( position, 1, "\\\\" );

If i change \\\\ to something like abasd the string will print out correct with abasd instead of \ .

I pull in 15k VMEM / second aka Memleak when i do \\\\

_________________
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
Goto page 1, 2  Next
Page 1 of 2

 
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