| View previous topic :: View next topic |
| Author |
Message |
HomerSexual Grandmaster Cheater Supreme
Reputation: 5
Joined: 03 Feb 2007 Posts: 1657
|
Posted: Sun May 04, 2008 10:17 am Post subject: Open With help |
|
|
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 |
|
 |
Stylo Grandmaster Cheater Supreme
Reputation: 3
Joined: 16 May 2007 Posts: 1073 Location: Israel
|
|
| Back to top |
|
 |
HomerSexual Grandmaster Cheater Supreme
Reputation: 5
Joined: 03 Feb 2007 Posts: 1657
|
Posted: Sun May 04, 2008 11:09 am Post subject: |
|
|
The problem is that when i do that, cPad opens and no files are there o.o _________________
|
|
| Back to top |
|
 |
Stylo Grandmaster Cheater Supreme
Reputation: 3
Joined: 16 May 2007 Posts: 1073 Location: Israel
|
Posted: Sun May 04, 2008 11:48 am Post subject: |
|
|
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 |
|
 |
HolyBlah Master Cheater
Reputation: 2
Joined: 24 Aug 2007 Posts: 446
|
Posted: Sun May 04, 2008 12:18 pm Post subject: |
|
|
| When you open a file with a program the system send the file path as the first parameter. |
|
| Back to top |
|
 |
HomerSexual Grandmaster Cheater Supreme
Reputation: 5
Joined: 03 Feb 2007 Posts: 1657
|
Posted: Sun May 04, 2008 12:21 pm Post subject: |
|
|
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 |
|
 |
tombana Master Cheater
Reputation: 2
Joined: 14 Jun 2007 Posts: 456 Location: The Netherlands
|
Posted: Sun May 04, 2008 12:48 pm Post subject: |
|
|
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 |
|
 |
HomerSexual Grandmaster Cheater Supreme
Reputation: 5
Joined: 03 Feb 2007 Posts: 1657
|
Posted: Sun May 04, 2008 12:57 pm Post subject: |
|
|
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 |
|
 |
HalfPrime Grandmaster Cheater
Reputation: 0
Joined: 12 Mar 2008 Posts: 532 Location: Right there...On your monitor
|
Posted: Sun May 04, 2008 1:01 pm Post subject: |
|
|
try getstartupinfo?
EDIT:
| Code: | int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance,
PSTR szCmdLine, int iCmdShow) |
szCmdLine may contain the extra info. _________________
|
|
| Back to top |
|
 |
Jani Grandmaster Cheater
Reputation: 2
Joined: 29 Dec 2006 Posts: 804
|
Posted: Sun May 04, 2008 2:04 pm Post subject: |
|
|
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 |
|
 |
atom0s Moderator
Reputation: 205
Joined: 25 Jan 2006 Posts: 8588 Location: 127.0.0.1
|
Posted: Sun May 04, 2008 2:33 pm Post subject: |
|
|
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 |
|
 |
HomerSexual Grandmaster Cheater Supreme
Reputation: 5
Joined: 03 Feb 2007 Posts: 1657
|
Posted: Sun May 04, 2008 2:40 pm Post subject: |
|
|
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 |
|
 |
Jani Grandmaster Cheater
Reputation: 2
Joined: 29 Dec 2006 Posts: 804
|
Posted: Sun May 04, 2008 2:58 pm Post subject: |
|
|
| 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 |
|
 |
atom0s Moderator
Reputation: 205
Joined: 25 Jan 2006 Posts: 8588 Location: 127.0.0.1
|
Posted: Sun May 04, 2008 6:07 pm Post subject: |
|
|
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 |
|
 |
HomerSexual Grandmaster Cheater Supreme
Reputation: 5
Joined: 03 Feb 2007 Posts: 1657
|
Posted: Sun May 04, 2008 9:15 pm Post subject: |
|
|
| 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 |
|
 |
|