General information
Category:
Windows API functions
It seems that what you do it's correct. I also tried it last night, but it fails to load the library whatever I did. Please let me know if you succed in using this from VFP.
Vlad
>>>I will try your pass by reference tomorrow and keep my fingers crossed. The DLL function I am trying to call has a callbank function as one of its arguments. How should I handle this? Does this mean I cannot use this function? If so, I'll have to use VB or VC++.
>>
>>It depends. Can you post here the samples you had in VC++ and VB? If it's an optional parameter (maybe you don't need to pass a callback function, maybe it's just if you want to change a default function?), than you may be able to use it. If it's a mandatory one... no way.
>
>I have included VB and VC++ code below. It looks like the callback function is optional.
>
>Thanks for everyone's help!
>
>********** Visual Basic Code **********
>
>Public Sub Main()
>Attribute Main.VB_Description = "->Used to start this program. Check it out!"
>Dim Err&
>Dim hOrgAPI As Long
>Dim InitFlag As Long
>Dim OrgRegCount As Long
>Dim Error_BadPassword As Boolean
>
>Dim ccMailDir As String
>Dim InfoBuffer As String
>Dim UserName As String
>Dim UserPassword As String
>
>' I cut out a bunch of code here
>
>frmCCMAIL_Start:
> 'If installation is cc:Mail, then show cc:Mail SignIn form
> If GetSetting(Appname:="Organizer BackPack", Section:="Session", Key:="Scheduling") = "cc:Mail" Then
>
> 'Display cc:Mail SignIn form
> ccMailDir = ""
> UserName = ""
> UserPassword = ""
> InitFlag& = OAIF_VALIDATE& Or OAIF_NOUI&
> 'If frmCCMAIL.Tag = "Cancel" then goto Cancel_Pressed
> 'Unload cc:Mail SignIn form
> End If
>
>Session_Start:
> '** {OrgAPIInit} Initialize an Organizer Session **
> hOrgAPI& = OrgAPIInit(0, 0, 0, 0, ccMailDir, UserName, UserPassword, InitFlag&, Err&)
> If hOrgAPI& = 0 Then
>
>' I cut out the rest of program
>
>********** Visual C++ Code **********
>
>// I cut this statement from the top of the C program
>
>/* Function pointer to error display routine */
>LPFNMESSAGEBOX lpfnMsgCallback;
>
>/****************************************************************************
> FUNCTION: ErrorHandler - Callback from InitApi and OrgAPIUIHandleError
> PURPOSE: Print all OrgApi Messages with our own MessageBox
>****************************************************************************/
>//LPFNMESSAGEBOX
>UINT CALLBACK _export ErrorHandler( HWND hWnd, LPCSTR lpszText, LPCSTR lpszCaption, UINT uiFlags )
>{
> LogIt("ErrorHandler %s %s",lpszText, lpszCaption);
> MessageBox( hWnd, lpszText, lpszCaption, uiFlags );
> return 0;
>}
>
>
>/****************************************************************************
> FUNCTION: InitApi
> PURPOSE: Do all the work required to Initialize an API session
>****************************************************************************/
>
>HORGAPI InitApi(HWND hwnd, HINSTANCE hThisInst, HINSTANCE hPrevInst,
> LPSTR lpszContainerPath, LPSTR lpszName, LPSTR lpszNamePassword)
>{
>long OrgAPIInitError;
>HORGAPI hOrgApi=0;
>
>lpfnMsgCallback = ErrorHandler;
>
>if(!APIVersion())
> OrgAPIUIHandleError(hOrgApi, hwnd, lpfnMsgCallback);
>
>hOrgApi = OrgAPIInit(hwnd, hThisInst, hPrevInst, lpfnMsgCallback,
> lpszContainerPath, lpszName, lpszNamePassword,
> OAIF_VALIDATE | OAIF_GRAYDIALOGS, (LPLONG)&OrgAPIInitError );
>
>// I cut out the rest of this function
Previous
Next
Reply
View the map of this thread
View the map of this thread starting from this message only
View all messages of this thread
View all messages of this thread starting from this message only