Measurement Studio for VC++

cancel
Showing results for 
Search instead for 
Did you mean: 

problem in dll

hi,
i want to know what is the function of _declspec(dllimport) ? because my project is that firstly my C++ program will input a integer into DLL, the variable in dll will be exported to LABVIEW program via the export function.I have written two export function in dll, one is for C++ input( say, export program a), another is for LABVIEW (export program b)and there is a variable called command in DLL program. I am not sure if this approach will work. because once i execute the C++ program ( different workspace with DLL program, that means there are two workspace), i think i can input the integer to dll, however, at the same time, when i open my labview and try to read this variable from program b, the error occur? does it mean that i cant access the same
DLL from C++ and labview at the same time? will the variable in dll change after i input the integer from C++ using export function?
can u suggest me some way or other approach to deal with it ? thanks for help a lot!
0 Kudos
Message 1 of 5
(3,137 Views)
I would suggest keeping the integer value internal to the DLL. Create a Read function and Write function that are both exported. Make sure you protect access to the integer variable using a synchronization technique (say semaphores).
For the definition of _declspec(dllimport), see the MSDN help online or from the MSDN Library CD that came with your copy of Microsoft Visual C++.
0 Kudos
Message 2 of 5
(3,137 Views)
thx for help randy.But i am doubt if my dll can be accessed from both C++ program and Labview. Because i have tried that. However the DLL can be accessed either C++ program or LabView only. if one side is accessing the dll, the other side will have error to run/execute the code. I am not really sure if this approachs work! also i want to know what's synchronization technique? and what's the meaning of the words semaphores? is that a special function in C++? Do you think there is only ActiveX control could solve my problem?
thx for all your help a lot! thx.

CowCow
0 Kudos
Message 3 of 5
(3,136 Views)
You may also want to investigate DataSocket for communication between the programs. Click here for more information.
From your comment, it seems you do not know much about data protection. I would suggest reading up on that material before you proceed with creating DLLs that multiple programs will use. There are many texts on this issue that can be found at many of the online book stores (amazon.com, bn.com, and so forth).
If all you are doing is passing information between the two programs, DataSocket is your best answer. You could also use tcp/ip.
0 Kudos
Message 4 of 5
(3,136 Views)
hi Randy,
thanks for give me a direction for my final year project. Thanks.

CowCow
0 Kudos
Message 5 of 5
(3,137 Views)