Post by UNDISCLOSED on May 3, 2009 10:25:42 GMT -5
I just started writing a DLL for downloading files from a url, it only has one function:
it should return true when it gets a file and false when an error occurs, but i just get "an eception occured" at the status bar in b4gl.
here is the code (For FreeBASIC):
Its mostly the sdk, but I removed the sample functions ect. and added my own description.
Can anybody help me?
result = HttpGet(byref url as string, byref target as string)
it should return true when it gets a file and false when an error occurs, but i just get "an eception occured" at the status bar in b4gl.
here is the code (For FreeBASIC):
'fbc -dll test01.bas
#include "Basic4GLPlugin.bi"
#include "windows.bi"
const PLUGIN_DESC = "HTTP file get Plugin for Basic4GL"
const PLUGIN_MAJOR = 0
const PLUGIN_MINOR = 1
extern "C"
' My httpget functon
private sub HTTPGET(THIS_RUNTIME)
DIM url as string = STR(GSP(1))
DIM target as string = STR(GSP(2))
Dim As Any Ptr library
Dim URLDownloadToFile As Function (Byval pCaller As Any Ptr, Byval szURL As String, _
Byval szFileName As String, Byval dwResv As Uinteger, Byval lpfnCB As Any Ptr) As Integer
library = Dylibload("urlmon")
If library = 0 Then SIR(0)
URLDownloadToFile = Dylibsymbol(library, "URLDownloadToFileA")
If URLDownloadToFile = 0 Then Dylibfree(library): SIR(0)
If URLDownloadToFile(0, url, target, 0, 0) Then Dylibfree(library): SIR(0)
Dylibfree(library)
SIR(-1)
end sub
' ##########
' # Plugin #
' ##########
dim shared as IDLL_Basic4GL_Plugin ptr MyPlugin
' register exported Datatypes,Const's,Function's,Sub's
function Load (THIS_PLUGIN , _
THIS_REGISTRY, _
blnIsExe as byte) as integer
'RegisterIntegerFunction(name,address):RegisterStringParam,RegisterStringParam
RIF(HTTPGET,@httpget):ASP:ASP
return 1
end function
' interface
sub Unload (THIS_PLUGIN)
if MyPlugin then
delete MyPlugin
MyPlugin = 0
end if
end sub
function Start(THIS_PLUGIN) as integer
return 1
end function
sub Ends (THIS_PLUGIN)
end sub
sub Pause (THIS_PLUGIN)
end sub
sub Resumed (THIS_PLUGIN)
end sub
sub DelayedResume (THIS_PLUGIN)
end sub
sub GetError (THIS_PLUGIN,ErrMsg as zstring ptr)
end sub
sub ProcessMessages(THIS_PLUGIN)
end sub
' Query function
function Basic4GL_Query alias "Basic4GL_Query" (byval details as string, _
byref major as integer, _
byref minor as integer) as integer export
dim as string DetailSrc = PLUGIN_DESC
for i as integer = 0 to len(detailSrc)
Details = DetailSrc
next
major = PLUGIN_MAJOR
minor = PLUGIN_MINOR
return BASIC4GL_DLL_VERSION
end function
' Main initialisation function.
' Here we will construct and return our plugin object
function Basic4GL_Init alias "Basic4GL_Init" () as IDLL_Basic4GL_Plugin ptr ptr export
' Construct and return our plugin object
MyPlugin=new IDLL_Basic4GL_Plugin
MyPlugin->Load =@load
MyPlugin->Unload =@unload
MyPlugin->Start =@start
MyPlugin->Ends =@ends
MyPlugin->Pause =@pause
MyPlugin->Resumed =@resumed
MyPlugin->DelayedResume =@delayedresume
MyPlugin->GetError =@geterror
MyPlugin->ProcessMessages=@processmessages
return @myplugin
end function
end extern
Its mostly the sdk, but I removed the sample functions ect. and added my own description.
Can anybody help me?