473,385 Members | 1,353 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,385 software developers and data experts.

PInvoke, marshalling bool as int

Hi

I'm writing the interop functions for functions in a C dll. All these functions return INT (32 signed). However, the return value is to be interpreted as a bool (false=0, true!=0). Can I do the following without problems

[DllImport("UsedLib.dll", EntryPoint="UsedFn")
[return : MarshalAs(UnmanagedType.I4)
public static extern bool UsedFn( )

Thank yo
--
Tom Tempelaere
Nov 16 '05 #1
2 1711
n!
> I'm writing the interop functions for functions in a C dll. All these
functions return INT (32 signed). However, the return value is to be
interpreted as a bool (false=0, true!=0). Can I do the following without
problems?

[DllImport("UsedLib.dll", EntryPoint="UsedFn")]
[return : MarshalAs(UnmanagedType.I4)]
public static extern bool UsedFn( );


Yes, I've used methods that define the return value as bool when it's really
an int.

n!
Nov 16 '05 #2
Thank yo
--
Tom Tempelaere.
Nov 16 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Shashank Date | last post by:
/* C# Gurus, I am trying to use interop marshalling to call SetCommTimeouts win32 API. But I keep getting the "Object reference not set to an instance of an object" error. Can anybody help...
4
by: TT (Tom Tempelaere) | last post by:
Hi people I am wrapping a C dll using PInvoke from C#. I need to wrap the following signature in C int dma_start( const UCHAR* data, UINT data_length ) The function should start with a DMA...
5
by: nicolasr | last post by:
Hi, I have the following PInvoke problem: I want to call the Win32 API SystemParametersInfo() which has the following signature: BOOL SystemParametersInfo( UINT uiAction, UINT uiParam,
7
by: Asfar | last post by:
I have a MFC dll in which one of the parameters is of LPSTR. The declaration of my MFC dll looks like extern "C" __declspec(dllexport) int WINAPI EXPORT TestPInvokeFunc(LPSTR szFileName, LPSTR...
3
by: msnews.microsoft.com | last post by:
Hi i am using User32.dll in Visual stdio 2005. public static extern long SetActiveWindow(long hwnd); public static extern long keybd_event(byte bVk, byte bScan, long dwFlags,
1
by: peary | last post by:
Hi, everyone, I'm writing a program to discover wireless network using Windows Native Wifi API & VB.net. I have to declare the windows API in my VB.net program. The original windows...
1
by: Beorne | last post by:
I have a cpp application with this structure: //////////////C++/////////////// typedef struct StatusStructure { char FixedLenString; long LongVariable; double DoubleVariable; BOOL...
4
by: Beorne | last post by:
I have to call a c++ library funtion with the following signature: void ReadBool(bool* pb1) unsafe static extern void NicamPLCRead(out bool); but this does not work, the bool (not...
1
by: =?iso-8859-1?B?S2VyZW0gR/xtcvxrY/w=?= | last post by:
Hi, i get a "Wrong Parameter" from Marshal.GetLastWin32Error() on using this: public class SP_DEVINFO_DATA { public int cbSize; public Guid classGuid;
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...
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
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

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.