|
-
June 10th, 2011, 03:52 PM
#1
[RESOLVED] Help line of C# to VB.Net
Could anyone here show me how to convert the code below to VB.Net
Code:
[DllImport("coredll.dll")]
private static extern int SystemParametersInfo(uint uiAction, uint uiParam, StringBuilder pvParam, uint fWiniIni);
Thanks
btw Using VS2005 but shouldn't make a difference
Always use [code][/code] tags when posting code.
-
June 10th, 2011, 03:59 PM
#2
Re: Help line of C# to VB.Net
Code:
<DllImport("coredll.dll")>
Private Shared Function SystemParametersInfo(ByVal uiAction As UInteger, ByVal uiParam As UInteger, ByVal pvParam As StringBuilder, ByVal fWiniIni As UInteger) As Integer
End Function
-
June 10th, 2011, 05:51 PM
#3
Re: Help line of C# to VB.Net
hmm, Thanks.. I had that in there before but was having an issue, looks like the issue is elsewhere.
I'm trying to detect when my app is running on a mobile device or in an emulator and found some code in C# to do this but my understanding of C# is not the greatest. I will keep working with it and see how it goes.
Always use [code][/code] tags when posting code.
-
June 11th, 2011, 02:06 PM
#4
Re: Help line of C# to VB.Net
http://blogs.msdn.com/b/oldnewthing/.../10000406.aspx
We would be able to help if you told us what the actual problem was/is.
-
June 11th, 2011, 10:42 PM
#5
Re: Help line of C# to VB.Net
Looks like I found the problem. Turns out I had 2 issues. The first was I had not added the proper Imports statement to get the DLLImport to work hence my thinking there was an issue with the way the line was formatted.
The other problem was I was creating an instance of the class and was getting a message that the line would not be evaluated. When I tried to reference the properties of said class. I can't remember the exact message now and I had tried a few different things since I posted.
Anyway I just now tried to reproduce the error and got it to work instead. Still not sure why exactly, maybe related to the Namespace tags I added as well as making a direct call to the routine without creating a new instance of the class.
Once I figure out exactly what the issue was I will post the results.
Always use [code][/code] tags when posting code.
-
June 13th, 2011, 09:28 PM
#6
Re: [RESOLVED] Help line of C# to VB.Net
Apparently my probelms were
1. I did not include the line
Imports System.Runtime.InteropServices
2. I was creating an instance of my class when what I actually needed was a reference to it instead.
Seems to be working fine now.
This is a big help for me as I write apps for handheld devices with barcode scanners and now can detect when they are being emulated so as to bypass the code which sets up the barcode scanner engine which would crash on the emulator. Now I shoudl be able to run on both the device and the emulator with no code changes.
Always use [code][/code] tags when posting code.
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
|