PocketMatrix forums

A read-only archive of the PocketMatrix forums (2001–2014). Posting and accounts are closed.

File association (registry) problem.

Hi,

I am writing my file association to the registry without any problems. However the changes are not notified to the system. How can this be done? In Win32 we can do:

SHChangeNotify(SHCNE_ASSOCCHANGED, SHCNF_IDLIST, 0, 0)

But it doesn't work with eVc.

Regards,
Kornalius
That isn't necessary. More than likely you are not properly creating the association (it takes two different keys per association). Does the association work after a soft reset?

Dan East
I did set the two keys.

HKEY_CLASSES_ROOT/.ppc (default=ppcfile)
HKEY_CLASSES_ROOT/ppcfile/Shell/Open/Command (default = \PPL.EXE %1)

But File Explorer still doesn't find the association.

Regards,
Kornalius
Hmm. Looks right to me. Does DEXplor's Association Editor see your association (you have to have the Registered version to use the Association Editor). However DEXplor does not use the Shell routines to figure out the icon for each file type - it figures that out on its own. So you might want to take a look at a .ppc file in DEXplor and see if it uses PPL.EXE's icon.

Dan East
Well, the icon is there (DefaultIcon \PPL.EXE -119) everything seems alright to me. Btw, I don't use DEXplorer, sorry. :( I do it with programming and the regular file explorer.

Is that all you do in DEXplorer, create the 2 keys in HKEY_CLASSES_ROOT? I mean, I tried resetting the device after the changes and it didn't work either. It is really driving me nuts.

Regards,
Kornalius
That's all I do in DEXplor to create / modify an association.

Dan East
Well then, thanks for your help Dan. I will keep looking into it. Maybe you take a look at this code and let me know if you see something strange. It is really not clean. I am planning on rewritting it when it works.

Code:
RegCreateKeyEx(HKEY_CLASSES_ROOT, L".ppc", 0, NULL, 0, KEY_ALL_ACCESS, NULL, &hKey;, &dwDisposition;);
ws = ToWideChar("ppcfile");
RegSetValueEx(hKey, NULL, 0, dwType, (byte *)ws, wcslen(ws)*sizeof(wchar_t));
free(ws);

ws = ToWideChar("PPC File");
RegSetValueEx(hKey, L"Content Type", 0, dwType, (byte *)ws, wcslen(ws)*sizeof(wchar_t));
free(ws);
RegCloseKey(hKey);

RegCreateKeyEx(HKEY_CLASSES_ROOT, L"ppcfile", 0, NULL, 0, KEY_ALL_ACCESS, NULL, &hKey;, &dwDisposition;);
ws = ToWideChar("PPC File");
RegSetValueEx(hKey, 0, NULL, dwType, (byte *)ws, wcslen(ws)*sizeof(wchar_t));
free(ws);
RegCloseKey(hKey);

sprintf(ss, "%s%s\0", root, "PPL.EXE,-119");
ws = ToWideChar(ss);
sz = MAX_PATH;
RegCreateKeyEx(HKEY_CLASSES_ROOT, L"ppcfile\\DefaultIcon", 0, NULL, 0, KEY_ALL_ACCESS, NULL, &hKey;, &dwDisposition;);
RegSetValueEx(hKey, 0, NULL, dwType, (byte *)ws, wcslen(ws)*sizeof(wchar_t));
RegCloseKey(hKey);

sprintf(ss, "%s%s\0", root, "PPL.EXE %1");
ws = ToWideChar(ss);
sz = MAX_PATH;
RegCreateKeyEx(HKEY_CLASSES_ROOT, L"ppcfile\\Shell\\Open\\Command", 0, NULL, 0, KEY_ALL_ACCESS, NULL, &hKey;, &dwDisposition;);
RegSetValueEx(hKey, 0, NULL, dwType, (byte *)ws, wcslen(ws)*sizeof(wchar_t));
RegCloseKey(hKey);


Regards,
Kornalius
The Content Type is not needed. Try omitting lines 6, 7 & 8. So when you look at the entries you created using some Registry Editor, how do they look? Do you see any problems?

Dan East
Hi Dan,

I checked the keys and they are all correct. I use Resco File Explorer (sorry your competitor I guess! :( ) It comes with a registry editor. When I associate the file (.ppc) with my program (PPL.exe) using the resco file explorer, it works. I don't see any other occurences of the ppc key or value in the registry other than the ones I create with my program.

This is very strange and I really can't get it to work.

I've attached a regtest.exe program. Can you test it and let me know if it works on your device?

Here is the source code:

Code:
#include "stdafx.h"
#include "utils.h"

int WINAPI WinMain( HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPTSTR lpCmdLine,
int nCmdShow)
{

char ss[255];
HKEY hKey = NULL;
DWORD dwDisposition = 0;
DWORD dwType = REG_SZ;
wchar_t *ws;

RegCreateKeyEx(HKEY_CLASSES_ROOT, L".ppc", 0, NULL, 0, KEY_ALL_ACCESS, NULL, &hKey;, &dwDisposition;);
ws = ToWideChar("ppcfile");
RegSetValueEx(hKey, NULL, 0, dwType, (byte *)ws, wcslen(ws)*sizeof(wchar_t));
free(ws);
RegCloseKey(hKey);

sprintf(ss, "%s\0", "\\PPL.exe,-119");
ws = ToWideChar(ss);
RegCreateKeyEx(HKEY_CLASSES_ROOT, L"ppcfile\\DefaultIcon", 0, NULL, 0, KEY_ALL_ACCESS, NULL, &hKey;, &dwDisposition;);
RegSetValueEx(hKey, 0, NULL, dwType, (byte *)ws, wcslen(ws)*sizeof(wchar_t));
RegCloseKey(hKey);
free(ws);

sprintf(ss, "\"%s\" %s\0", "\\PPL.EXE", "%1");
ws = ToWideChar(ss);
RegCreateKeyEx(HKEY_CLASSES_ROOT, L"ppcfile\\Shell\\Open\\Command", 0, NULL, 0, KEY_ALL_ACCESS, NULL, &hKey;, &dwDisposition;);
RegSetValueEx(hKey, 0, NULL, dwType, (byte *)ws, wcslen(ws)*sizeof(wchar_t));
RegCloseKey(hKey);
free(ws);

MyMessageBox("Done!", "REGTEST", MB_OK);

return 0;
}


Regards,
Kornalius[/code]
Attachments:
regtest.zip (2 KB)
That binary won't run on my PPC 2000 iPaq 3630.

Dan East
Here's a bug. All instances of:

wcslen(ws)*sizeof(wchar_t)

should be:

(wcslen(ws)+1)*sizeof(wchar_t)

You need to include the null terminator in the buffer size.

Dan East
Hi Dan,

I gonna try this and let ya know. Maybe that was really the problem all along. I hope so! :D

Regards,
Kornalius
Sorry for the delay Dan, I was having some other more important problems with the compiler and the interpreter that just showed up when I tried to execute a big .ppl program. I was use to test everything with small program files. :cry: Man what a surprise when I compiled this big text editor program. hehe! :D It's now fine and it allowed me to optimized some parts and to find some bugs in other places.

Anyway, I tested the registry keys with the fix you proposed and it didn't do anything. Of course it's safer this way but still doesn't work. There is got to be another key or something that I am missing. I use Resco File Explorer to assign the file and it works. My keys are all there and Resco File Explorer seem to be creating the same keys only. It is very strange and without this the product is not going to be as nice to use. :cry:

Btw, thank you very much for all your generous help, it is very appreciated. It's not easy to find help on the PPC programming. I can honestly say that PM as allowed me to bring this product to (almost as of now) completion.

Regards,
Kornalius