Skip to content

Commit

Permalink
fix current directory bug #1
Browse files Browse the repository at this point in the history
作業フォルダーが変わった場合にfontsを参照できない問題を修正
  • Loading branch information
khsk committed May 15, 2022
1 parent 97bc998 commit c16221d
Showing 1 changed file with 26 additions and 5 deletions.
31 changes: 26 additions & 5 deletions localfont.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,34 @@ BOOL WINAPI DllMain( HINSTANCE hInstance,DWORD dwNotification,LPVOID lpReserved
switch (dwNotification) {
case DLL_PROCESS_ATTACH:
// exe直下でもplugins内設置でもカレントはaviutl.exe直下になる
if (!PathIsDirectory(FONTS_DIR)) {
MessageBox(NULL, TEXT("Fonts directory is missing"),NULL, MB_OK);
// ただしGUIからのexeの直接起動と異なりショートカット経由や外部呼出しではカレントは異なる場合があるため、相対パスではAviUtil内のfontsを参照できなかったりカレント内の意図しないfontsフォルダを参照してしまう場合があるのでこれは行わない

// if (PathIsDirectory(FONTS_DIR)) {
// setFontFiles(FONTS_DIR);
// return TRUE;
// }

// カレントを使用せずに実行中ファイルのパスからAviUtl直下を算出する
TCHAR modulePath[MAX_PATH];
if (!GetModuleFileName(0, modulePath, MAX_PATH)) {
MessageBox(NULL, TEXT("Error: GetModuleFileName"),NULL, MB_OK);
return TRUE;
}
setFontFiles(FONTS_DIR);
}
if(PathRemoveFileSpec(modulePath) == 0) {
MessageBox(NULL, TEXT("Error: PathRemoveFileSpec"),NULL, MB_OK);
MessageBox(NULL, TEXT(modulePath),NULL, MB_OK);
return TRUE;
}
std::string modulePathString = modulePath;
std::string fontsFullPath = modulePathString + "\\" + FONTS_DIR;
if (!PathIsDirectory(fontsFullPath.c_str())) {
MessageBox(NULL, TEXT("Fonts directory is missing"),NULL, MB_OK);
MessageBox(NULL, fontsFullPath.c_str(),NULL, MB_OK);
} else {
setFontFiles(fontsFullPath);
}
}
return TRUE;
}

int main(int, char**) {}
int main(int, char**) {}

0 comments on commit c16221d

Please sign in to comment.