[IronPython] Null pointer passing

Michael Foord fuzzyman at voidspace.org.uk
Mon Dec 17 13:25:52 CET 2007


Try IntPtr.Zero

Michael
http://www.manning.com/foord

Kaveripakam, Sathish wrote:
> HI All,
>  
> I am trying to call  Windows CreateFile function from iron Python. I 
> have a dll (c# dll , which has "extern entry" to Create File and I am 
> importing  Kernel32.dll). The problem is, when I am trying to pass the 
> arguments, which is of null type, I used "None" in the iron python.  
> But during execution, I get an error saying that "Expected IntPtr but 
> got NoneType".
>  
> Could you please let me know, if I am missing something, which is 
> primitive .
>  
>  
> *Iron python Call:*
>  
> x = Win_dll.CreateFile( '\\\\.\\TEST\\test',
>                                     GENERIC_READ|GENERIC_WRITE ,
>                                     FILE_SHARE_READ|FILE_SHARE_WRITE,
>                                     None,
>                                     OPEN_EXISTING,
>                                     FILE_FLAG_WRITE_THROUGH,
>                                     None
>                                 )
>  
>
> public class Win_dll{
>
>                     [DllImport("Kernel32.dll")]
>
>                   public static extern IntPtr CreateFile( string 
> FileName, uint DesiredAccess, uint ShareMode,IntPtr 
> SecurityAttributes,uint CreationDisposition,uint 
> FlagsAndAttributes,IntPtr TemplateFile);
>
> }}
>
> ------------------------------------------------------------------------
> _Legal Notice:_
> The information in this electronic transmission may contain 
> confidential or legally privileged information and is intended solely 
> for the individual(s) named above. If you are not an intended 
> recipient or an authorized agent, you are hereby notified that 
> reading, distributing, or otherwise disseminating, copying or taking 
> any action based on the contents of this transmission is strictly 
> prohibited. Any unauthorized interception of this transmission is 
> illegal under law. If you have received this transmission in error, 
> please notify the sender by telephone [at the number indicated 
> above/on +41 58 928 0101] as soon as possible and then destroy all 
> copies of this transmission. 
> ------------------------------------------------------------------------
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> Users mailing list
> Users at lists.ironpython.com
> http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
>   




More information about the Ironpython-users mailing list