我有一個關於函數指針的基本問題。 在下面的代碼片段中,我該如何閱讀「 *(FARPROC*)&pfn =
」?函數指針基本問題
IFastString *CallCreateFastString(const char *psz) {
static IFastString * (*pfn)(const char *) = 0;
if (!pfn) {
const TCHAR szDll[] = _TEXT("FastString.DLL");
const char szFn[] = "CreateFastString";
HINSTANCE h = LoadLibrary(szDll);
if (h)
*(FARPROC*)&pfn = GetProcAddress(h, szFn);
}
return pfn ? pfn(psz) : 0;
}
看一看在文檔'GetProcAddress'-你會看到,上面的情況是令人費解... http://msdn.microsoft.com/en-us/library/ms683212(v=vs.85).aspx – Nim