/    Sign up×
Community /Pin to ProfileBookmark

Calling a DLL function

Hello,

I’ve been trying to work something out for a while and I’m just getting no where.

I have some embedded javascript code that creates an active X object,which is a DLL that is in the registry also (sorry if the terminology is not quite correct here). Along with this DLL came a sample VB application, which I have been using to understand the functions available.

I’m having a real problem in trying to understand how to convert the following VB code to Javascript:

Call AK.GetCDListRecord(lngLoop, lngHA, lngTGT, lngLUN, lngPAD, strID)

I’ve tried the following:

ak.GetCDListRecord(0, lngHA, lngTGT, lngLUN, lngPAD, strID);

but this doesn’t appear to be returning anything into lngHA, lngTGT, etc.

I’d rather try and keep this in javascript since I already have other stuff in javascript at this stage. I am by no means a javascript expert but I’d love to get this resolved.

I’d appreciate any help/direction.

Thanks.

to post a comment
JavaScript

4 Comments(s)

Copy linkTweet thisAlerts:
@CrazyMerlinJan 05.2006 — It won't in javascript.

You are most likely losing focus of those variables.

You need to create them in javascript at the start of the first instance of script, but outside of any function. That way they are pseudo-global.

Even still, you may lose scope as the DLL won't know that the variable it is setting are for the document. You may need a HTA document to get this to work properly.

Is there no way you can rewrite that particular function into javascript?

You can happily mix vbscript and javascript in the same page, and so using vbscript may be more prevalent to what you want to achieve.

What DLL is it? I have studio.NET 2005 and so may be able to find the issue.

Let me know.
Copy linkTweet thisAlerts:
@dtwconsultingauthorJan 06.2006 — Merlin,

The DLL is part of AKRip which I got from SourceForge. It provides FreeDB access and access to the client CD drive. I know about the secuity issues but this is just something that I am working on for me ? and slowly I might add. I have this working with gracenote CDDB since they provide the DLL's and they seem to work just fine from embedded javascript

I tried to do this in embedded VBScript but I'm still having problems ?

Here is the actual VB Code:

Dim AK As AKRipAX.AKRip

Private Sub Form_Load()

'Initialse Component

Set AK = New AKRipAX.AKRip

End Sub

Private Sub cmdGetCDList_Click()

Dim lngHA As Long

Dim lngTGT As Long

Dim lngLUN As Long

Dim lngPAD As Long

Dim strID As String

Dim strVendor As String

Dim strProductID As String

Dim strRevision As String

Dim strVendorSpec As String

Dim lngLoop As Long

txtCDInfo.Text = ""

AK.GetCDList

If AK.GetCDListCount = 0 Then

txtCDInfo.Text = "No CD Drives Found"

Else

For lngLoop = 0 To AK.GetCDListCount - 1

If txtCDInfo.Text <> "" Then txtCDInfo.Text = txtCDInfo.Text & vbCrLf

Call AK.GetCDListRecord(lngLoop, lngHA, lngTGT, lngLUN, lngPAD, strID)

txtCDInfo.Text = txtCDInfo.Text & "CD " & lngLoop + 1 & " Record" & vbCrLf & vbCrLf

txtCDInfo.Text = txtCDInfo.Text & "HA = " & lngHA & vbCrLf

txtCDInfo.Text = txtCDInfo.Text & "TGT = " & lngTGT & vbCrLf

txtCDInfo.Text = txtCDInfo.Text & "LUN = " & lngLUN & vbCrLf

txtCDInfo.Text = txtCDInfo.Text & "PAD = " & lngPAD & vbCrLf

txtCDInfo.Text = txtCDInfo.Text & "ID = " & strID & vbCrLf & vbCrLf

Call AK.GetCDListInfo(lngLoop, strVendor, strProductID, strRevision, strVendorSpec)

txtCDInfo.Text = txtCDInfo.Text & "CD " & lngLoop + 1 & " Information" & vbCrLf & vbCrLf

txtCDInfo.Text = txtCDInfo.Text & "Vendor = " & strVendor & vbCrLf

txtCDInfo.Text = txtCDInfo.Text & "ProductID = " & strProductID & vbCrLf

txtCDInfo.Text = txtCDInfo.Text & "Revision = " & strRevision & vbCrLf

txtCDInfo.Text = txtCDInfo.Text & "VendorSpec = " & strVendorSpec & vbCrLf

Next lngLoop

End If

End Sub

This is the embedded VBScript that I wrote...and it doesn't work ?

<script language="VBScript">

Function GetCDList()

Dim lngHA As Long

Dim lngTGT As Long

Dim lngLUN As Long

Dim lngPAD As Long

Dim strID As String

Dim strVendor As String

Dim strProductID As String

Dim strRevision As String

Dim strVendorSpec As String

Dim lngLoop As Long

Set AK = CreateObject("AKRipAX.AKRip")

AK.GetCDList

If AK.GetCDListCount = 0 Then

MsgBox "No CD Drives Found"

End If

Call AK.GetCDListRecord(0, lngHA, lngTGT, lngLUN, lngPAD, strID)

MsgBox "I'm HERE"

End Function

</script>

When I run the page it tells me that there is an error on the first Dim line at position 11. Looks like it doesn't like the As Long piece of the Dim.

Really at a loss as to how to get this to work ?

Wish it was easier to find a good ActiveX wrapper that provides CD and FreeDB functions.

Any help is much appreciated
Copy linkTweet thisAlerts:
@CrazyMerlinJan 06.2006 — I think you'll find that vbscript weakly typed, so no need for 'As' appendages, just use Dim lngHA

When you create the object, you may need to just write:

Set AK = CreateObject("AKRipAX")

as AKRipAX is the library that you want to create an instance of, and AKRip is a class of that library.

If you post a link to the DLL, I'll try and get it to work.

Thx
Copy linkTweet thisAlerts:
@dtwconsultingauthorJan 06.2006 — Merlin,

Certainly appreciate your help on this. I took out all the As Types and I'm getting further. Now I am stuck with the following line:

Call AK.GetCDListRecord(0, lngHA, lngTGT, lngLUN, lngPAD, strID)

The error I am now getting is as follows:-

Type Mismatch: 'AK.GetCDListRecord'

So, I guess I am getting closer but still can't get the damn thing to work ?

Here is the link to AKRip.

[URL=http://akrip.sourceforge.net/]AKRip[/URL]

Go to the download sections and then from there you need to download the following file:

AKRipAX-20010801.zip, which contains the AKRipAX.dll file which can be created in the registry by executing the install.bat.

Again, appreciate the help and many thanks.
×

Success!

Help @dtwconsulting spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.24,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...