473,320 Members | 1,876 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 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 2392
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: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.