By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,952 Members | 1,619 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,952 IT Pros & Developers. It's quick & easy.

return an integer value from vc++ to c# wcf

P: 2
Hi all,

I have to return an integer value from vc++ to c# wcf. In vc++ the function works fine but in c# the function returns wrong integer value.

In vc++
Expand|Select|Wrap|Line Numbers
  1. typedef struct  
  2. {
  3.     BOOL bALerm1;
  4.     BOOL bALerm2; 
  5.     BYTE bLevel;
  6. }myStruct, 
  7.  
  8. __declspec(dllexport)  static int   getStatus();//declaration
  9.  
  10. ClassA theApp;//object creation
  11.  
  12. int  ClassA::getStatus()
  13. {         
  14.         myStruct tmpASS; 
  15.         int status=-1;
  16.             tmpASS=myObj->GetZoneStatus();  //assgn value 
  17.              if (tmpASS.bALerm1==TRUE) 
  18.              { 
  19.               status=1; 
  20.              }
  21.             else
  22.              { 
  23.               status=0; 
  24.              }   
  25.         }  
  26.         return status;
  27.  }
  28.  
  29. extern "C"    __declspec(dllexport) int  getStatus()
  30. {
  31.     return theApp.getStatus();
  32. }
In C# side
Expand|Select|Wrap|Line Numbers
  1. [DllImport("myDll.dll", SetLastError = true,
  2.     CallingConvention = CallingConvention.Cdecl)]
  3.      public static extern int getStatus();
  4.  
  5. int status=getStatus();
Always returns 0,can any one help please!

Thanks
May 30 '12 #1
Share this question for a faster answer!
Share on Google+

Post your reply

Sign in to post your reply or Sign up for a free account.