Hola, estoy intentando hacer un programa en VB a partir de una dll hecha con C++ en objetos. El programa consiste en introducir el nombre, uso de cpu y memoria de un proceso, y luego mostrarlo, todo va bien hasta que se le da a mostrar, entonces me sale el error 49: "La convencion de llamadas a DLL es incorrecta". Alguien sabria decirme donde esta el fallo?
Gracias.
Adjunto código.
CProcess.h
typedef char Tpalabra [20];
class CProcess
{
private:
Tpalabra imageName;
float cpuUsage;
int memUsage;
public:
CProcess();
void pon_imageName(Tpalabra name);
Tpalabra* dame_imageName();
void pon_cpuUsage(float cpu);
float dame_cpuUsage();
void pon_memUsage(int mem);
int dame_memUsage();
float valor_inicial_cpu();
int valor_inical_mem();
};
CProcess.cpp
#include "CProcess.h"
#include <string.h>
Tpalabra newProc;
CProcess::CProcess()
{
strcpy(imageName,newProc);
cpuUsage=0.0;
memUsage=0;
}
float CProcess::valor_inicial_cpu()
{
return cpuUsage;
}
int CProcess::valor_inical_mem()
{
return memUsage;
}
void CProcess::pon_imageName(Tpalabra name)
{
strcpy(imageName,name);
}
Tpalabra* CProcess::dame_imageName()
{
return (&imageName);
}
void CProcess::pon_cpuUsage(float cpu)
{
cpuUsage=cpu;
}
float CProcess::dame_cpuUsage()
{
return (cpuUsage);
}
void CProcess::pon_memUsage(int mem)
{
memUsage=mem;
}
int CProcess::dame_memUsage()
{
return (memUsage);
}
DLLCProcess.cpp
#include "Windows.h"
#include "CProcess.h"
CProcess my_Process;
void FAR PASCAL DLLpon_imageName(Tpalabra name)
{
my_Process.pon_imageName(name);
}
void FAR PASCAL DLLdame_imageName(Tpalabra name)
{
strcpy(name,*my_Process.dame_imageName());
}
void FAR PASCAL DLLpon_cpuUsage(float cpu)
{
my_Process.pon_cpuUsage(cpu);
}
float FAR PASCAL DLLdame_cpuUsage()
{
return my_Process.dame_cpuUsage();
}
void FAR PASCAL DLLpon_memUsage(int mem)
{
my_Process.pon_memUsage(mem);
}
int FAR PASCAL DLLdame_memUsage()
{
return my_Process.dame_memUsage();
}
CProcess.def
LIBRARY CProcess.dll
DESCRIPTION 'Dll CProcess'
HEAPSIZE 4024
EXPORTS
DLLpon_imageName @1
DLLdame_imageName @2
DLLpon_cpuUsage @3
DLLdame_cpuUsage @4
DLLpon_memUsage @5
DLLdame_memUsage @6
VB
Form 1
Option Explicit
Private Sub Command1_Click()
Dim name As String
Dim cpu As Single
Dim mem As Long
name = " "
name_in.Text = name
cpu_in.Text = cpu
mem_in.Text = mem
DLLpon_imageName (name)
DLLpon_cpuUsage (cpu)
DLLpon_memUsage (mem)
MsgBox "Datos introducidos correctamente"
End Sub
Private Sub Command2_Click()
Dim palabra As String
Dim cpuUsage As Single
Dim memUsage As Long
palabra = " "
DLLdame_imageName palabra
DLLdame_cpuUsage cpuUsage
DLLdame_memUsage memUsage
name_out.Text = palabra
cpu_out.Text = cpuUsage
mem_out.Text = memUsage
End Sub
Module1
Option Explicit
Public Declare Function DLLpon_imageName _
Lib "CProcess.dll" _
(ByVal name As String) _
As Long
Public Declare Function DLLdame_imageName _
Lib "CProcess.dll" _
(ByVal imageName As String) _
As Long
Public Declare Function DLLpon_cpuUsage _
Lib "CProcess.dll" _
(ByVal cpu As Single) _
As Long
Public Declare Function DLLdame_cpuUsage _
Lib "CProcess.dll" _
(ByVal cpuUsage As Single) _
As Long
Public Declare Function DLLpon_memUsage _
Lib "CProcess.dll" _
(ByVal mem As Long) _
As Long
Public Declare Function DLLdame_memUsage _
Lib "CProcess.dll" _
(ByVal memUsage As Long) _
As Long
PD: Hay alguna manera de no meter un codigo tan largo en un post? Comprimirlo o algo asi?