Jump to content

Help With Self-created Dll


Recommended Posts

Hi @ all!

I am a Auto-It newbie, and so i created some functions for me in an external dll. The DLL is written in PowerBasic, and the DLL is called "OEMConvert.dll".

FUNCTION OEMConv(path AS STRING) AS LONG

(..codesnippets...)

END FUNCTION

Now I try to call the function in AU3 now:

global $Path = @ScriptDir & "\OEMConvert.dll"

$DLLVar = DllCall ($Path, "long", "OEMConv","Str","TODO.dat" )

But $DLLVar is "0", and nothing happens. (But in the dll are at least 1 MsgBox, which shows some variables for debugging)

Whats wrong here?

Thanks for help and for reading my bad english grammar-text.

Gr33tz

Tafkadasom2k5

Link to comment
Share on other sites

Hi @ all!

I am a Auto-It newbie, and so i created some functions for me in an external dll. The DLL is written in PowerBasic, and the DLL is called "OEMConvert.dll".

FUNCTION OEMConv(path AS STRING) AS LONG

(..codesnippets...)

END FUNCTION

Now I try to call the function in AU3 now:

global $Path = @ScriptDir & "\OEMConvert.dll"

$DLLVar = DllCall ($Path, "long", "OEMConv","Str","TODO.dat" )

But $DLLVar is "0", and nothing happens. (But in the dll are at least 1 MsgBox, which shows some variables for debugging)

Whats wrong here?

Thanks for help and for reading my bad english grammar-text.

Gr33tz

Tafkadasom2k5

You have to check @error macro if DllCall was successful. Also note, if dll was called successfuly, $DLLVar will be array, where first element is result of called function, other - parameters passed to the dll.

Btw, if your goal is converting Ascii to Ansi - this can be done in pure Autoit with one call.

Link to comment
Share on other sites

OK, thanks first.

But why doesn't the dll work?

The First line in the dll is a MessageRequester which shows all variables, which are given to it.

Should i do something like this?

while @error
  $DLLVar = DllCall ("OEMConve.dll", "long", "OEMConv","Str","TODO.dat" )
wend

I don't think that this makes sense.

Whats wrong with the DLLCall in my source?!

Or how can i change a complete File from Ascii to Ansi?

Youre right, thats my goal.

But normally that should work with my self created function, too.

Edited by Tafkadasom2k5
Link to comment
Share on other sites

OK, thanks first.

But why doesn't the dll work?

Whats wrong with the DLLCall in my source?!

But normally that should work with my self created function, too.

Hm, call looks correct. What value @error have just after call? Maybe problem with your dll export, do you checked if dll have exactly OEMConv function (not suffixed by something like @nn)?

Or how can i change a complete File from Ascii to Ansi?

For beta version, though.

$asciiText = FileRead($sFileName, FileGetSize($sFileName))
$ansiText = Ascii2ansi($asciiText)
FileWrite($sOutFileName, $ansiText)

Func Ascii2ansi($sText)
  Local $src = DllStructCreate("char[" & StringLen($sText) + 1 & "]")
  Local $dst = DllStructCreate("char[" & StringLen($sText) + 1 & "]")
  DllStructSetData($src, 1, $sText)
  DllCall("user32.dll", "int", "OemToCharA", "ptr", DllStructGetPtr($src), "ptr", DllStructGetPtr($dst))
  Return DllStructGetData($dst, 1)
EndFunc
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...