TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Vikram
1.5k
276
308k
Call VC++ dll in C# Application
Apr 12 2012 11:43 AM
HI,
we are using one c++ dll to read data from Hardware. Following is the function defination from C++ dll.
LRESULT CALLBACK MT_Read_Holding_Reg(long llSocketHandle,UCHAR lucDevID,USHORT lunAddress,USHORT lunQuantity, USHORT* lunHLData);
To Call this from C# I have written following code:
[DllImport("MT_TCP_Read.dll", CharSet = CharSet.Ansi, SetLastError = true, ExactSpelling = true)]
public static extern int MT_Read_Input_Reg(int llSocketHandle, byte lucDevID, short lunAddress, short lunQuantity, ref short lunHLData);
and while calling this function I have writtten following code:
short[] arr_hg = new short[3];
int ret = -1;
ret = MT_Read_Coils(handle, 1, 100, 3, ref arr_coils[0]);
This function return no data where as same dll used in VB6 return correct data.
Is there any problem in above code.
Any help appreciated.
Regards,
Vikram
Reply
Answers (
2
)
Using WinForms and WPF in the same project
How to count condition datagrid?