472,982 Members | 2,381 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,982 software developers and data experts.

Call Windows API from VB.Net?

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
5 2364
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
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
* "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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: clusardi2k | last post by:
Hello, I have a shared drive on SGI, Linux, and Windows. A second call to fopen doesn't create the file if it has been deleted. I would like to use fopen for its pointer return value to...
3
by: David N | last post by:
Hi All, I just wonder if in C#, I can develop a user defined control that can call its parent function which is not yet developed. For example, how do I make my user control call a...
3
by: dotNETDavid | last post by:
We've broken our app into various assemblies. The WinForm assembly provides the user interface, other assemblies provide various I/O services. I'd like to be able to call...
2
by: PawelR | last post by:
Hello Group, In my application I have few class, and I want call function with "master class". This is as master form (startClass) and option window (ClassA). My question is how call function...
10
by: Clint | last post by:
Hey all - I'm having a really confusing problem concerning a web service. Right now, I have an application that needs to call a web service that does nothing but return "true" (this will...
1
by: Abdalla Fawaz El-Hawary | last post by:
I have a solution includes 2 projects the 1st one is a class library project and the 2nd is windows application. Normally i can use the classes wich in the 1st project(DLL) after add refrence for...
5
by: Kurt Van Campenhout | last post by:
Hi, I am trying to get/set Terminal server information in the active directory on a windows 2000 domain. Since the ADSI calls for TS don't work until W2K3, I need to do it myself. I'm fairly...
5
by: Stephen Barrett | last post by:
I have read many threads related to async fire and forget type calls, but none have addressed my particular problem. I have a webpage that instantiates a BL object and makes a method call. The...
0
by: Nickneem | last post by:
I' m trying to disable all right mouse clicks by using the vbAccelerator Windows Hooks Library The small (systray / console) app. must catch all (right) mouseclicks before they are received by...
3
by: forest demon | last post by:
for example, let's say I do something like, System.Diagnostics.Process.Start("notepad.exe","sample.txt"); if the user does a SaveAs (in notepad), how can i capture the path that the user...
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 4 Oct 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
2
by: giovanniandrean | last post by:
The energy model is structured as follows and uses excel sheets to give input data: 1-Utility.py contains all the functions needed to calculate the variables and other minor things (mentions...
4
NeoPa
by: NeoPa | last post by:
Hello everyone. I find myself stuck trying to find the VBA way to get Access to create a PDF of the currently-selected (and open) object (Form or Report). I know it can be done by selecting :...
1
by: Teri B | last post by:
Hi, I have created a sub-form Roles. In my course form the user selects the roles assigned to the course. 0ne-to-many. One course many roles. Then I created a report based on the Course form and...
3
by: nia12 | last post by:
Hi there, I am very new to Access so apologies if any of this is obvious/not clear. I am creating a data collection tool for health care employees to complete. It consists of a number of...
0
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be focusing on the Report (clsReport) class. This simply handles making the calling Form invisible until all of the Reports opened by it have been closed, when it...
0
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...
4
by: GKJR | last post by:
Does anyone have a recommendation to build a standalone application to replace an Access database? I have my bookkeeping software I developed in Access that I would like to make available to other...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.