-
conversion problems
I have an API I have to interact with which was originally written in Delphi.
It contains a method which needs an integer passed to it which represents the handle to the current window.
The problem is that in .net as far as I can see the handle to the current window is of IntPtr type and cannot be converted to an int type.
e.g.
Code:
System.IntPtr myHandle = this.Handle;
workflowAPI.myMethod(Convert.ToInt32(myHandle));
Error "Unable to cast object of type System.IntPtr" to type "System.IConvertible"
Any Ideas Chaps and Chapesses ?
:wave:
-
Re: conversion problems
Why, is it too hot for you? :rofl:
Try
Code:
[DllImport("user32.dll")]
public static extern int FindWindow(string strclassName, string strWindowName);
Then use FindWindow to get the int value, passing it to myMethod. Just remember not to fly off it during the process. :rofl: :rofl: :rofl: :rofl:
-
Re: conversion problems
Try the IntPtr.ToInt32 method.
-
Re: conversion problems
Or declare the parameter as IntPtr in the first place; assuming it's a standard DLL.
-
Re: conversion problems
Thanks all
I ended up parsing it to string and it magically worked.
-
Re: conversion problems
I like overcomplicating everything.