使用Load-Time動態連結

建立 DLL 之後,您可以使用它在應用程式中定義的函式。 以下是使用從 Myputs.dll (匯出的 myPuts 函式的簡單主控台應用程式,請參閱 建立簡單Dynamic-Link程式庫) 。

因為這個範例會明確呼叫 DLL 函式,所以應用程式的模組必須與匯入程式庫 Myputs.lib 連結。 如需建置 DLL 的詳細資訊,請參閱開發工具隨附的檔。

#include <windows.h> 

extern "C" int __cdecl myPuts(LPCWSTR);   // a function from a DLL

int main(VOID) 
{ 
    int Ret = 1;

    Ret = myPuts(L"Message sent to the DLL function\n"); 
    return Ret;
}

載入時間動態連結