Setting a private variable in a dll (noobie)

  • Thread starter Aristotelis E. Charalampakis
  • Start date
A

Aristotelis E. Charalampakis

Hi everyone, this is a newbie question...

I have a dll written in c++. This dll is called from a executable written
in VB 6.0

I want to use a variable (say a float) within multiple functions in the dll.
I also want to retrieve, set or change the value of this variable within the
dll at any time using functions such as, say, SetVariable1 or GetVariable1
from my exe program.

Can I do this? ( I use stdcall and all the names of the external functions
are in a .def file)

Tia,

Aristotelis
 
L

lallous

"Aristotelis E. Charalampakis"
Hi everyone, this is a newbie question...

I have a dll written in c++. This dll is called from a executable written
in VB 6.0

I want to use a variable (say a float) within multiple functions in the dll.
I also want to retrieve, set or change the value of this variable within the
dll at any time using functions such as, say, SetVariable1 or GetVariable1
from my exe program.

Can I do this? ( I use stdcall and all the names of the external functions
are in a .def file)

Tia,

Aristotelis
Hello,

You can have a global float variable in your DLL, and export set/get methods
so that they are called from your VB application...

float g_val1;

// exported function
void SetValue1(float f)
{
g_val = f;
}

void GetValue1(float &f)
{
f = g_val1;
}

However if you have further questions regarding DLL issues or other non
strictly C++ issue, ask in microsoft.public.vc.language
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,767
Messages
2,569,572
Members
45,045
Latest member
DRCM

Latest Threads

Top