By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
457,696 Members | 1,486 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 457,696 IT Pros & Developers. It's quick & easy.

Call Windows API from VB.Net?

P: n/a
Hi, all!! Using VB.Net and VS/2003.

I'm trying to call standard Windows API calls from VB.NET, but keep getting
an "Unhandled Exception of type 'System.NotSupportedExtension' occurred in
myApp.exe". The call that's failing is CreateFile; all user types have been
converted to STRUCTURES, and all ANYs have been converted to a type that is
appropriate.

Any ideas? I'm sure this is something basic that I'm overlooking...
Thanks!
Jack
Nov 20 '05 #1
Share this Question
Share on Google+
5 Replies


P: n/a
Hi Jack,

This is a very simple Api I am busy with now.

I hope this sample helps?

Cor

Public Structure SYSTEMTIME
Public Year As Short
Public Month As Short
Public DayOfWeek As Short
Public Day As Short
Public Hour As Short
Public Minute As Short
Public Second As Short
Public Milliseconds As Short
End Structure
Public Declare Sub GetSystemTime _
Lib "kernel32" Alias "GetSystemTime" _
(ByRef lpSystemTime As SYSTEMTIME)
Private Sub Form1_Load(ByVal sender _
As System.Object, ByVal e As System.EventArgs) _
Handles MyBase.Load
Dim systime As SYSTEMTIME
GetSystemTime(systime)
MsgBox(systime.Year.ToString())
End Sub
Nov 20 '05 #2

P: n/a
Hi,

Here is the api declare and structure.

Declare Function CreateFile Lib "kernel32" Alias "CreateFileA" _
(ByVal lpFileName As String, ByVal dwDesiredAccess As Integer, _
ByVal dwShareMode As Integer, ByVal lpSecurityAttributes As
SECURITY_ATTRIBUTES, _
ByVal dwCreationDisposition As Integer, ByVal dwFlagsAndAttributes
As Integer, _
ByVal hTemplateFile As Intptr) As Intptr

Structure SECURITY_ATTRIBUTES
Dim nLength As Integer
Dim lpSecurityDescriptor As Integer
Dim bInheritHandle As Integer
End Structure

Ken
-----------------------------
"Jack Black" <ja*************@hotmail.com> wrote in message
news:O2**************@TK2MSFTNGP12.phx.gbl...
Hi, all!! Using VB.Net and VS/2003.

I'm trying to call standard Windows API calls from VB.NET, but keep
getting
an "Unhandled Exception of type 'System.NotSupportedExtension' occurred in
myApp.exe". The call that's failing is CreateFile; all user types have
been
converted to STRUCTURES, and all ANYs have been converted to a type that
is
appropriate.

Any ideas? I'm sure this is something basic that I'm overlooking...
Thanks!
Jack

Nov 20 '05 #3

P: n/a
* "Jack Black" <ja*************@hotmail.com> scripsit:
I'm trying to call standard Windows API calls from VB.NET, but keep getting
an "Unhandled Exception of type 'System.NotSupportedExtension' occurred in
myApp.exe". The call that's failing is CreateFile; all user types have been
converted to STRUCTURES, and all ANYs have been converted to a type that is
appropriate.


I assume that your declares and structures are not correct. Post your code.

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>
Nov 20 '05 #4

P: n/a
On Sun, 25 Apr 2004 00:19:25 -0700, Jack Black wrote:
Hi, all!! Using VB.Net and VS/2003.

I'm trying to call standard Windows API calls from VB.NET, but keep getting
an "Unhandled Exception of type 'System.NotSupportedExtension' occurred in
myApp.exe". The call that's failing is CreateFile; all user types have been
converted to STRUCTURES, and all ANYs have been converted to a type that is
appropriate.

Any ideas? I'm sure this is something basic that I'm overlooking...
Thanks!
Jack


I have a .dll written in C# (and the source code) for a set of shared
classes that have virtually all the api's. I did not write the classes and
do know where I obtained them. I THINK it was on gotdotnet.com. The api's
are grouped logically. Since they are shared classes, they are called
easily.

For example, to call the CreateFile method, you would use the following:

Win32.Kernel.CreateFile(....)

Of Course you can use the Imports statement to import any of the
namespaces.

I attempted to attach a zipped version of the source code but it was
rejected as too large (86K).

If you are interested, please send me an EMail (be sure to remove the anti
spam portion).

If someone knows who created these classes, I would like to know. I would
also like to find some public place that these classes could be made
available.

--
Chris

To send me an E-mail, remove the underscores and lunchmeat from my E-Mail
address.
Nov 20 '05 #5

P: n/a
I'd like to see this as well...

cege at [[tavayn] [[[dot] [com]]]]

remove the '[ and ]

"Chris Dunaway" <dunawayc@_lunchmeat_sbcglobal.net> wrote in message
news:iy*****************************@40tude.net...
On Sun, 25 Apr 2004 00:19:25 -0700, Jack Black wrote:
Hi, all!! Using VB.Net and VS/2003.

I'm trying to call standard Windows API calls from VB.NET, but keep getting an "Unhandled Exception of type 'System.NotSupportedExtension' occurred in myApp.exe". The call that's failing is CreateFile; all user types have been converted to STRUCTURES, and all ANYs have been converted to a type that is appropriate.

Any ideas? I'm sure this is something basic that I'm overlooking...
Thanks!
Jack
I have a .dll written in C# (and the source code) for a set of shared
classes that have virtually all the api's. I did not write the classes

and do know where I obtained them. I THINK it was on gotdotnet.com. The api's are grouped logically. Since they are shared classes, they are called
easily.

For example, to call the CreateFile method, you would use the following:

Win32.Kernel.CreateFile(....)

Of Course you can use the Imports statement to import any of the
namespaces.

I attempted to attach a zipped version of the source code but it was
rejected as too large (86K).

If you are interested, please send me an EMail (be sure to remove the anti
spam portion).

If someone knows who created these classes, I would like to know. I would
also like to find some public place that these classes could be made
available.

--
Chris

To send me an E-mail, remove the underscores and lunchmeat from my E-Mail
address.

Nov 20 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.