Jump to content

Recommended Posts

Posted

olá!!!

Estou a fazer um programa em C, para somar duas variáveis. mas não consigo aceder á função que soma as variáveis, que está numa dll.

a dll foi desenvolvida em VB.NET e é a seguinte:

Public Class Class1

    Function addiction(ByVal x As Integer, ByVal y As Integer) As Integer
        Dim result As Integer

        result = x + y

        Return result
    End Function
End Class

o código em C é este:

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <windows.h>

typedef int (*Soma_ptr)();
Soma_ptr somar=NULL;

int main(int argc, char *argv[])
{
int num;
  	HMODULE dll = LoadLibrary("SomaTeste.dll");
  	if(dll)
  		somar = (Soma_ptr) GetProcAddress(dll, "addiction");
  	num = somar(1,5);
  	printf("O Resultado e': %d\n",num);
  	system("PAUSE");
  	return 0;
}

Alguem me pode ajudar...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site you accept our Terms of Use and Privacy Policy. We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.