Valhalla Legends Forums Archive | .NET Platform | [C++.NET] Using a .DLL

AuthorMessageTime
bethra
Um I'm trying to use BnetAuth.dll in my program but I can't seem to figure out how.

I've tried using google, but it doesn't bring up much help because they require these other files with it i.e. ".obj", ".lib"

How the heck am I suppose to use the DLL?
February 11, 2005, 9:21 AM
shout
I don't know how to do that but because bnetauth.dll is in C++ you could just stick the code in your program. Give credit though if you do.
February 11, 2005, 3:48 PM
K
[code]
// ret_type (* calling_conv pfFunc) (arg_list)
typedef int (*_stdcall pfDllFunc)(int arg1, char* arg2);

HMODULE h = LoadLibrary("mydll.dll");
if (!h)
{
  // error: dll couldn't be loaded or not found.
}

pfDllFunc func = (pfDllFunc)GetProcAddress(h, "FunctionName");
if (!func)
{
  // error: address of function not found in dll
}

int return_value = func(12, "hello");
[/code]
February 11, 2005, 7:07 PM
bethra
[quote author=K link=topic=10514.msg99308#msg99308 date=1108148861]
[code]
// ret_type (* calling_conv pfFunc) (arg_list)
typedef int (*_stdcall pfDllFunc)(int arg1, char* arg2);

HMODULE h = LoadLibrary("mydll.dll");
if (!h)
{
  // error: dll couldn't be loaded or not found.
}

pfDllFunc func = (pfDllFunc)GetProcAddress(h, "FunctionName");
if (!func)
{
  // error: address of function not found in dll
}

int return_value = func(12, "hello");
[/code]
[/quote]

okie, it loads the dll fine, but it can't find the address of the function.

this is the function that it can't address, its directly from the header file that declares it:
[code]
__declspec(dllexport)
BOOL _stdcall PasswordHash(char *OutBuf, DWORD encryptvalue, char *password);
[/code]

Here is what I did to address it:
[code]
typedef BOOL (*_stdcall PasswordHash)(char *OutBuf, DWORD encryptvalue, char *password);
HMODULE h = LoadLibrary("BnetAuth.dll");

if (!h){
printf("[Error] DLL couldn't be loaded or not found.\n");
}
PasswordHash passhash = (PasswordHash)GetProcAddress(h, "PasswordHash");
if (!passhash){
printf("[Error] Address of function not found in DLL.\n");
}
[/code]

February 11, 2005, 11:19 PM
K
is "PasswordHash" the exact name of the function? Did you get the capitalization right? You can check it out using dependancy walker or some other tool.
February 12, 2005, 1:12 AM

Search