|
-
Sep 13th, 2006, 04:17 AM
#1
Thread Starter
Fanatic Member
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 ?
-
Sep 13th, 2006, 04:35 AM
#2
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:
-
Sep 13th, 2006, 04:42 AM
#3
Re: conversion problems
Try the IntPtr.ToInt32 method.
-
Sep 13th, 2006, 04:54 AM
#4
Re: conversion problems
Or declare the parameter as IntPtr in the first place; assuming it's a standard DLL.
-
Sep 13th, 2006, 05:05 AM
#5
Thread Starter
Fanatic Member
Re: conversion problems
Thanks all
I ended up parsing it to string and it magically worked.
-
Sep 13th, 2006, 05:51 AM
#6
Re: conversion problems
I like overcomplicating everything.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|