*******************UseDll1.cpp*********************
#include
typedef int (*function1_ptr) ();
function1_ptr function1=NULL;
int APIENTR
Just because the code runs and exits doesn't mean it's right! Are you sure that:
You should step through the code in a debugger to make sure all this is happening and that the code does get to function1(). If it does then my guess would be that your email function has a bug in it.
Have you verify that you have all external dependencies for "DLL1.dll" ?
LoadLibrary will fail even if any of the indirect linked-library is not available.
Why not debug it and see where it fails? Make sure your dll is actually being loaded(it could simply be a path issue or a bad dll(you might have not imported/exported the functions).
Find out where the issue is first. It's either in loading the dll, calling the function, or inside the function
Thank you very much, your web page helped me a lot :) I only had to use tchar.h to make it working. You can see it in the rest of the answer.
#pragma once
#include <windows.h>
#include "spinapi.h"
#include <tchar.h>
typedef int (*count_boards_ptr)(void);
int x = 0;
HINSTANCE hinstDLL;
hinstDLL = LoadLibrary(_T("C:\\Smajdalf\\doucko_C\\DLLProblem\\DLLProblem\\spinapi.dll"));
count_boards_ptr count_boards = NULL;
count_boards = (count_boards_ptr) GetProcAddress(hinstDLL, "pb_count_boards");
if(count_boards != NULL) {
x = count_boards();
}
FreeLibrary(hinstDLL);
I had the same issue. This link resolved it. The issue was that I was not using _T macro.
I think you have already checked existence of dll.
Now Try this ::
Try to change "Any CPU" to 86 or 64.
Try to run your application as administrator.