Server Intellect
 
Home   Asp.Net Tutorials   What's New   Newsletter   More Resources
 
 
  Categories
Advanced Technologies
AJAX
Internet Browsers
Controls
Database
Email
Error Handling
File
Graphics
Website Navigation
Network
Performance
User Interface and Themes
Validation
Visual Web Developer
Web Services
XML
Suggest Tutorial


Navigator: Home - Tutorials - Controls - A sample of invoking Win32 API in ASP.NET 2.0 (VB.NET)
A sample of invoking Win32 API in ASP.NET 2.0 (VB.NET)


ASP.NET Controls Tutorial

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

I just signed up at Server Intellect and couldn't be more pleased with my Windows Server! Check it out and see for yourself.

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 />
&nbsp;
<asp:Label ID="lblTime" runat="server" Width="136px"></asp:Label></div>
</form>
</body>
</html>

If you're looking for a really good web host, try Server Intellect - we found the setup procedure and control panel, very easy to adapt to and their IT team is awesome!

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

Download the Full Working Version of this Project written with Visual Studio.NET VB.NET 2005 Here!

Looking for the C#.NET 2005 Version? Click Here!

Looking for more ASP.NET Tutorials? Click Here!







 
  Developer Resources







Server Intellect Rocks