File Extension
Hi, i am working on a simple model viewer for rendering 3d models in real time. I keep my model files, fx. files, apllication file and all the other stuff in a folder. In the same folder i have also a config file (for example we can call it config.jjj).
That config file keeps the data like object position, rotation, scale, color ...... When i run the application, at first it looks the data in the config file and than it opens the model file and render it according the data
taken from config file. Now i want to make some changes like that; first of all i need to move my config file in to another location in my computer like desktop. Secondly i need to change file extension of my config file to when i run it, it should call the main viewer application like a shortcut file(it must run the application file from it's own folder because otherwise the application couldn't find the path of object file).
Lastly when the config file calls the application it must send config.jjj files path to the application because when the application starts it should read the data in config file.
Is there anybody knows anything about this ? Thanks for your help.
Quote:Original post by sansured
first of all i need to move my config file in to another location in my computer like desktop.
So, do so.
You need to decide how the program will know where the config file is, and you should make sure you understand about absolute vs. relative path names. Otherwise there should be no real problem.
Quote:Secondly i need to change file extension of my config file to when i run it, it should call the main viewer application like a shortcut file(it must run the application file from it's own folder because otherwise the application couldn't find the path of object file).
This requires understanding something about the registry.
Quote:Lastly when the config file calls the application it must send config.jjj files path to the application because when the application starts it should read the data in config file.
AFAIK this will happen automatically; after you register the .jjj extension, double-clicking the .jjj file will cause Windows to start your program, and pass the full path to the file in argv[1].
assuming you are using windows, you could do something like:
I used this a while back so it's a bit messy.
<app path> - absolute path of .exe file
<icon path> - the icon you want to be display for the file type(absolute path)
HKEY hKeyMain; HKEY hKey; HRESULT hd = RegCreateKeyEx(HKEY_CLASSES_ROOT, L".jjj", 0, NULL, REG_OPTION_NON_VOLATILE, KEY_CREATE_SUB_KEY | KEY_SET_VALUE, NULL, &hKeyMain, NULL); if(hd != ERROR_SUCCESS) { MessageBox(NULL, L"Could Not set registry key.", NULL, NULL); } else { RegSetValue(hKeyMain, NULL, REG_SZ, L"JJJ", 3); RegCreateKeyEx(HKEY_CLASSES_ROOT, L"JJJ", 0, NULL, REG_OPTION_NON_VOLATILE, KEY_CREATE_SUB_KEY, NULL, &hKeyMain, NULL); // add this if you want an icon // RegCreateKeyEx(hKeyMain, L"DefaultIcon", 0, NULL, REG_OPTION_NON_VOLATILE, KEY_CREATE_SUB_KEY | KEY_SET_VALUE, NULL, &hKey, NULL); // RegSetValue(hKey, NULL, REG_SZ, L"<icon path>", 31); RegCreateKeyEx(hKeyMain, L"shell", 0, NULL, REG_OPTION_NON_VOLATILE, KEY_CREATE_SUB_KEY, NULL, &hKey, NULL); RegCreateKeyEx(hKey, L"open", 0, NULL, REG_OPTION_NON_VOLATILE, KEY_CREATE_SUB_KEY, NULL, &hKey, NULL); RegCreateKeyEx(hKey, L"command", 0, NULL, REG_OPTION_NON_VOLATILE, KEY_CREATE_SUB_KEY | KEY_SET_VALUE, NULL, &hKey, NULL); RegSetValue(hKey, NULL, REG_SZ, L"\"<app path>" \"%1\"", 27); } RegCloseKey(hKey);
I used this a while back so it's a bit messy.
<app path> - absolute path of .exe file
<icon path> - the icon you want to be display for the file type(absolute path)
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement