MCPcopy Create free account
hub / github.com/assimp/assimp / MakeFileAssociations

Function MakeFileAssociations

tools/assimp_view/MessageProc.cpp:88–123  ·  view source on GitHub ↗

------------------------------------------------------------------------------- Setup file associations for all formats supported by the library File associations are registered in HKCU\Software\Classes. They might be overwritten by global file associations. -------------------------------------------------------------------------------

Source from the content-addressed store, hash-verified

86// be overwritten by global file associations.
87//-------------------------------------------------------------------------------
88void MakeFileAssociations() {
89 char szTemp2[MAX_PATH];
90 char szTemp[MAX_PATH + 10];
91
92 GetModuleFileName(nullptr,szTemp2,MAX_PATH);
93 sprintf(szTemp,"%s %%1",szTemp2);
94
95 HKEY hRegistry = nullptr;
96
97 aiString list, tmp;
98 aiGetExtensionList(&list);
99 tmp = list;
100
101 const char* sz = strtok(list.data,";");
102 do {
103 char buf[256];
104 ai_assert(sz[0] == '*');
105 sprintf(buf,"Software\\Classes\\%s",sz+1);
106
107 RegCreateKeyEx(HKEY_CURRENT_USER,buf,0,nullptr,0,KEY_ALL_ACCESS, nullptr, &hRegistry,nullptr);
108 RegSetValueEx(hRegistry,"",0,REG_SZ,(const BYTE*)"ASSIMPVIEW_CLASS",(DWORD)strlen("ASSIMPVIEW_CLASS")+1);
109 RegCloseKey(hRegistry);
110 } while ((sz = strtok(nullptr,";")) != nullptr);
111
112 RegCreateKeyEx(HKEY_CURRENT_USER,"Software\\Classes\\ASSIMPVIEW_CLASS",0,nullptr,0,KEY_ALL_ACCESS, nullptr, &hRegistry,nullptr);
113 RegCloseKey(hRegistry);
114
115 RegCreateKeyEx(HKEY_CURRENT_USER,"Software\\Classes\\ASSIMPVIEW_CLASS\\shell\\open\\command",0,nullptr,0,KEY_ALL_ACCESS, nullptr, &hRegistry,nullptr);
116 RegSetValueEx(hRegistry,"",0,REG_SZ,(const BYTE*)szTemp,(DWORD)strlen(szTemp)+1);
117 RegCloseKey(hRegistry);
118
119 CLogDisplay::Instance().AddEntry("[OK] File associations have been registered",
120 D3DCOLOR_ARGB(0xFF,0,0xFF,0));
121
122 CLogDisplay::Instance().AddEntry(tmp.data,D3DCOLOR_ARGB(0xFF,0,0xFF,0));
123}
124
125//-------------------------------------------------------------------------------
126// Handle command line parameters

Callers 1

MessageProcFunction · 0.85

Calls 3

aiGetExtensionListFunction · 0.85
InstanceClass · 0.85
AddEntryMethod · 0.45

Tested by

no test coverage detected