Important Message

You are browsing the archived Lancers Reactor forums. You cannot register or login.
The content may be outdated and links may not be functional.


To get the latest in Freelancer news, mods, modding and downloads, go to
The-Starport

VB and FL_CODEC

Advertise for Modelers, Programmers, Webmasters, INI Editors, Script Experts, Adventurers, Servers, or anything that has to do with a project

Post Mon Dec 13, 2004 6:15 am

VB and FL_CODEC

Hi
I'm going to use the VB Code of the FLCodec File.
I wrote an Programm in C++ to create a textfile of a *.fl file. But now I'm going to try this in VB for using in a new program.
The decleration of this dll is :
Public Declare Function flcodec Lib "c:\windows\system32\flcodec.dll" (ByVal nType As Long, ByVal szSource As String, ByVal szDest As String) As Long

a) if i declare this function as public the program returned an error because to declare a function in the main-decleration is not allowed
b) There is given a variable named "nType" . Should be a "Long". What number is preferred by the dll? I tried it out with 0,1 and 2. But: No effect, no error, no systemcrash....

I will be happy if someone has an idea how to fix my problem.

Sorry for my mistakes. Only a pupil and from Germany

Post Tue Dec 14, 2004 3:19 am

BlackIce,
we'll muddle through. Your English is much better than my German.

I think all of your problems are due to some requirements of VB for certain uses. I assume you are writing this as a VB application? If so, and if you are declaring this in your Form code, the problem is that you can't make it public there since it can't be shared from a Form. If your application source code is just the Form, make it "Private Declare".

Here's how I declare the function and the flags. I use names that are somewhat "friendlier" to non-coders:

<pre><font size=1 face=Courier>
Private Declare Function flcodec Lib "flcodec" _
(ByVal codecFlag As Long, ByVal sourcePath As String, _
ByVal targetPath As String) As Long

' flcodec flags
Private Const FLCODEC_DECODE = &H1
Private Const FLCODEC_ENCODE = &H2
</font></pre>

Note also that I ABSOLUTELY DO NOT use an explicit complete path to flcodec.dll - i just say "flcodec". If it is in the same folder as your application or in your system search path, the application will have no problem finding the file. Specifying the full path is an invitation to breakage.

OK, now that I've said that... here's how I use it. You can paste the following function into your form code and then call the function with the original savegame path and the new path as arguments. If the file is decoded successfully, it returns True. If it fails, it returns False. If flcodec wasn't found, it spits an error message out.


<pre><font size=1 face=Courier>
Private Function EncodeSaveGame(ByVal sourcePath As String, _
ByVal targetPath As String) As Boolean
On Error GoTo CodecError:
Dim MyLastCodecError As Boolean
MyLastCodecError = flcodec(FLCODEC_ENCODE, sourcePath, targetPath)
On Error GoTo 0
If MyLastCodecError = 0 Then
EncodeSaveGame = True
Else
EncodeSaveGame = False
End If
Exit Function
CodecError:
Err.Raise Err.Number, TypeName(Me), _
"Error calling flcodec.dll. Make certain it is available in your path or the current working directory."
End Function
</font></pre>

Return to Help Wanted/Available Section