Help with using DLLs

Hello, since this appears to be a new forum perhaps I can get some help. I am having the darnest time working with DLLs. I have found snippits here and there, but no concrete complete example programs. My question: Can someone show me a complete program that loads a dll and then executes a function from that dll I have included my first feeble attempt at what seems to me shouldn't be so difficult. The code runs but the dll is not loaded.

#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <windows.h>
#include <psapi.h>

using namespace std;

int main(){
HANDLE hPsapi = LoadLibrary("C:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\psapi.dll");
if(hPsapi)
printf("DLL Loaded\n");
else
printf("DLL Not Loaded\n");

CloseHandle(hPsapi);
}


Answer this question

Help with using DLLs

  • theikell

    MSDN

    P.S>   Make sure to use correct string literals.   "C:\Progr..."  is not correct.  Use double "\\" in strings. I.e.

    "C:\\Program Files\\MyFolder\\MyFile.dll"

     


  • Help with using DLLs