473,324 Members | 2,473 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,324 software developers and data experts.

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

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
0 1374

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

Similar topics

7
by: Sashi | last post by:
Two questions: (1) I can pull the text of an XML element as a string just fine using code as such: strSomeString = myXmlDoc.SelectSingleNode("/Element1/Element2/Element3",...
5
by: Robert Wilson | last post by:
Hi, I'm a little new to C#, so bear with me. I have a text box on a form, and I want to be able to get an integer value of whats in it. In VC++ you just set the text box property to be numerals...
4
by: OutdoorGuy | last post by:
Greetings, I am attempting to compile the code below, but I am receiving an error message when I do so. The error message is: "CSO161: 'Forloop.CalcAvg(int)': Not all code paths return a...
3
by: Mark Jones | last post by:
I need a little hlep. Can anyone show me how to use RNGCryptoServiceProvider to return an integer value within a specified range using vb.net? The function would look something like this ...
7
by: Robert | last post by:
I have the function below. it returns a "simpleresult" which I've also included the definition of below. In VS2005 (after upgrading the project), I get a warning indicating that Function...
5
by: Joergen Bech | last post by:
Basically, I want to convert hex values in the range "00000000" to "FFFFFFFF" to a signed, 32-bit Integer value. In VB6, I could just write lngValue = Val(hexstring$). In VB.Net, I seem to be...
25
by: guy | last post by:
i have inherited the following migrated vb6 code (vb2005) but i DONT get the "not all paths return a value" squiggly - is this a 'feature' of on error goto? Private Function CreateFolder(ByVal...
12
by: Abhishek | last post by:
now suppose I have declared an integer value inside a function as int x; now if the return type of the function is of type (void *) then can I write return((void *)x) in side the function? I...
4
by: a | last post by:
I have been cleaning up somebody else's code in Vs2005 .net 2.0 There wer lots of these code pat errors because of unitialized variables in functions with Conditionals - that may or may not be...
2
by: ELINTPimp | last post by:
Hello all, Have a really interesting problem (at least to me) with my upload_file() function. I have it working now, with a bit of a work around, but would like to know what everyone thinks in...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.