Converting Windows Form code to ASP.NET

Posted on 2006-04-25
Last Modified: 2012-08-14

    I have a requirement to implement a USB security key into the security model of our software.  I purchased an evaluation kit from a company who claims it has a number of clients who use the dongle in ASP.NET applications.  The sample code is VB.NET, but its windows form.  The steps I have taken so far don't produce an error, but it also doesn't work.  The lines of code that I think are giving me the problem are the ones that refer to the DLL.

Declare Function KFUNC Lib "KL2DLL32.DLL" Alias "_KFUNC@16" (ByVal arg1 As Integer, ByVal arg2 As Integer, ByVal arg3 As Integer, ByVal arg4 As Integer) As Integer
Does anyone have experience in migrating from to or recognize how the statement above may be the problem OR have any ideas on how to move forward through this?

Question by:clintnash
    LVL 6

    Accepted Solution

    Change it to:

    Private Declare Auto Function KFUNC Lib "KL2DLL32.DLL" Alias "_KFUNC@16" (ByVal arg1 As Integer, ByVal arg2 As Integer, ByVal arg3 As Integer, ByVal arg4 As Integer) As Integer

    Then it should be all right.

    LVL 6

    Expert Comment

    Please test the following code with an web page, it runs well on my computer.

        Private Declare Function GetWindowsDirectory Lib "kernel32" Alias "GetWindowsDirectoryA" (ByVal lpBuffer As String, ByVal nSize As Long) As Long

        Public Function GetWinPath()
            Dim strFolder As String
            Dim lngResult As Long
            strFolder = New String(Chr(0), 255)
            lngResult = GetWindowsDirectory(strFolder, 255)
            If lngResult <> 0 Then
                GetWinPath = Left(strFolder, InStr(strFolder, Chr(0)) - 1)
                GetWinPath = ""
            End If
        End Function

        Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
            If Not Page.IsPostBack() Then
                Label1.Text = GetWinPath()
            End If
        End Sub

    I think there shouldn't be any difference between windows forms and pages when calling an API. But the reason of your error might be: Your IIS allows Anonymous Access, but the anonymous user doesn't have the permission to Execute an API.

    Featured Post

    What Should I Do With This Threat Intelligence?

    Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

    Join & Write a Comment

    One of the pain points with developing AJAX, JavaScript, JQuery, and other client-side behaviors is that JavaScript doesn’t allow for cross domain request for pulling content. For example, JavaScript code on could not pull conte…
    Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
    Sending a Secure fax is easy with eFax Corporate ( First, Just open a new email message.  In the To field, type your recipient's fax number You can even send a secure international fax — just include t…
    This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

    746 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    16 Experts available now in Live!

    Get 1:1 Help Now