

Navigator : Home > Tutorials > Controls Tutorials > ...
A sample of invoking Win32 API in ASP.NET 2.0 (VB.NET)
This tutorial show you a simple example to explain how to invoke Win32 API in ASP.NET 2.0 and VB.NET.
To invoke Win32 API using ASP.NET 2.0 and C# 2.0 is actually very simple.
First, you will need to import the namespaces
Imports System.Net Imports System.Text.RegularExpressions Imports System.Text Imports System.Runtime.InteropServices |
If you're ever in the market for some great Windows web hosting, try Server Intellect. We have been very pleased with their services and most importantly, technical support.
Then, add two controls to web page, a Button and a Label control
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="_Default" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" > <head runat="server"> <title>A sample of invoking Win32 API in ASP.NET 2.0 VB</title> </head> <body> <form id="form1" runat="server">
<div> <strong>Test Your Click Interval</strong><br /> <br /> <asp:Button ID="btnSubmit" runat="server" Text="Click Me!" /> <br /> <br /> <asp:Label ID="lblTime" runat="server" Width="136px"></asp:Label></div> </form> </body> </html> |
Add a function for displaying the time interval between mouse clicks of the button
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim CurrentTime As Long If Not Page.IsPostBack Then
lblTime.Text = "" CurrentTime = 0 Session("LastTime") = New Long() Session("Frequency") = New Long() If Not QueryPerformanceFrequency(Session("Frequency")) Then
lblTime.Text = "Error:Server doesn't support performance counter" btnSubmit.Enabled = False End If Else
If QueryPerformanceCounter(CurrentTime) And Session("LastTime") <> 0 Then lblTime.Text = lblTime.Text & ((CurrentTime - Session("LastTime")) / Session("Frequency")).ToString() & "second since last click.<br>" Else
lblTime.Text = lblTime.Text & "Please click again.<br>" End If Session("LastTime") = CurrentTime End If End Sub |
We used over 10 web hosting companies before we found Server Intellect. Their dedicated servers and add-ons were setup swiftly, in less than 24 hours. We were able to confirm our order over the phone. They respond to our inquiries within an hour. Server Intellect's customer support and assistance are the best we've ever experienced.
Looking for the C#.NET 2005 Version? Click Here!
Looking for more ASP.NET Tutorials? Click Here!