こんな感じです
int AAAA(char *pszSrcPath, char *pszLzhFilePath)
{
HINSTANCE hXXXX;
PFUNC pcsFunc;
int iResult;
char *pszHomeDir;
char szHomeDir[MAX_PATH];
char *pszLastSep;
// カレントディレクトリ取得
pszHomeDir = getcwd(szHomeDir, MAX_PATH);
strcpy(szParentDir, "D:\\TEMP");
// 対象データが存在するディレクトリに移動する
chdir(szParentDir);
iResult = -1;
// DLL読込
hXXXX = LoadLibrary("XXXXX.dll");
if (hXXXX != NULL) {
// Unlha()APIの呼び出し
pcsFunc = (PFUNC)GetProcAddress(hUnlha, "YYY");
if (pcsFunc != NULL) {
iResult = (*(pcsFunc)(FALSE);
}
// DLL解放
// →ここまではszHomeDirは正しい
FreeLibrary(hXXXX);
// →ここにくると、szHomeDirの先頭4バイトが別な値に書き換えられる。
}
chdir(szHomeDir);
return(iResult);

}