DLL's call
1, VB
Public Declare Function findpath Lib "Zd/ly_cstar_vb.dll" (ByVal Starx As Integer, ByVal StarY As Integer, ByVal stopx as Integer, ByVal stopy As Integer, ByVal Space As Integer, ByVal mapsrc as String, ByVal clickxy As Integer, ByVal sn as Str ing) as String
Private Sub Command1_Click ()
Dim SS as String
SS = Findpath (154, 0, "Zd/1.bmp", 2, "dl_8889888")
If SS <> "-1" Then
MsgBox (SS)
End If
End Sub
Note that VB can not pass the variable assignment variable return like Delphi, so it makes a function Findpath with return value, and passes the string in Pchar type.
2. Easy language
. Version 2
. DLL command Findpath, logic type, "Ly_cstar.dll", "Findpath"
. parameter Starx, integer type
. parameter StarY, integer type
. parameter stopx, integer type
. parameter stopy, integer type
. parameter Space, integer type
. parameter mapsrc, text type
. parameter Clickxy, integer type
. parameter sn, text type
. parameter outstring, integer type, transmit address
. local variable DD, integer type
. local variable SS, logic type
SS = Findpath (418, 117, 261, 0, "2.bmp", 2, "dl_8889888", DD)
. if (SS)
info box ("Calculated value:" + Pointer to text (DD), 0,)
. otherwise
Information box ("Setting parameters cannot be reached here:", 0,)
COM DLL mode
3. TC
Start button _ Click action
function Start _ Click ()
TS = com ("DL.") Cstar ")//Create plug-in object com keyword must be lowercase
Ss= TS. Findpath (111,41,23,85,0, "C:\\users\\momo\\desktop\\c Star Quest Validator \\pic\\1004.bmp", 2, "Security Code")
Auxiliary. Message box (SS)
End of function
4. Key Wizard
Ss=plugin.dl_cstar.findpath (154,39,35,210,0, "Map\1.bmp", 2, "dl_8889888")
MessageBox SS
5. Delphi
Unit Unit2;
Interface
Uses
Windows, Messages, sysutils, variants, Classes, Graphics, Controls, Forms,
Dialogs, Stdctrls;
Type
TForm2 = Class (Tform)
Button1:tbutton;
Procedure Button1Click (Sender:tobject);
Private
{Private declarations}
Public
{Public declarations}
End
Var
Form2:tform2;
Implementation
{$R *.DFM}
------------------------------------------------------------------------------Freeing Resources automatically
function Findpath (Starx, StarY, Stopx, Stopy, Space:integer; Mapsrc:pansichar; Clickxy:integer; Sn:pansichar;var Outstring:pansichar): Boolean;stdcall; External ' Zd/ly_cstar.dll ';//name ' FindPath2 '
//------------------------------------------------------------------------------//
Procedure Tform2.button1click (Sender:tobject);
Var
Ss:pansichar;
Begin
If Findpath (154,39,35,210,0, ' zd/1.bmp ', 2, ' dl_8889888 ', ss) then
ShowMessage (ss);
End
End.
7, VC
FffDlg.cpp:implementation file
//
#include "stdafx.h"
#include "fff.h"
#include "FffDlg.h"
#ifdef _DEBUG
#define NEW Debug_new
#undef This_file
static char this_file[] = __file__;
#endif
/////////////////////////////////////////////////////////////////////////////
Cfffdlg Dialog
Cfffdlg::cfffdlg (cwnd* pparent/*=null*/)
: CDialog (Cfffdlg::idd, pparent)
{
{{Afx_data_init (CFFFDLG)
Note:the ClassWizard would add member initialization here
}}afx_data_init
Note that LoadIcon does isn't require a subsequent destroyicon in Win32
M_hicon = AfxGetApp ()->loadicon (IDR_MAINFRAME);
}
void Cfffdlg::D odataexchange (cdataexchange* PDX)
{
CDialog::D odataexchange (PDX);
{{Afx_data_map (CFFFDLG)
Note:the ClassWizard would add DDX and DDV calls here
}}afx_data_map
}
Begin_message_map (Cfffdlg, CDialog)
{{Afx_msg_map (CFFFDLG)
On_wm_paint ()
On_wm_querydragicon ()
}}afx_msg_map
End_message_map ()
/////////////////////////////////////////////////////////////////////////////
CFFFDLG message handlers
BOOL Cfffdlg::oninitdialog ()
{
CDialog::OnInitDialog ();
Set The icon for this dialog. The framework does this automatically
When the application ' s main window was not a dialog
SetIcon (M_hicon, TRUE);//Set big icon
SetIcon (M_hicon, FALSE);//Set Small icon
Todo:add Extra initialization here
return TRUE; Return TRUE unless you set the focus to a control
}
If you add a Minimize button to your dialog, you'll need the code below
To draw the icon. For MFC applications using the Document/view model,
This is automatically do for your by the framework.
void Cfffdlg::onpaint ()
{
if (Isiconic ())
{
CPAINTDC DC (this); Device context for painting
SendMessage (Wm_iconerasebkgnd, (WPARAM) DC. GETSAFEHDC (), 0);
Center icon in client rectangle
int cxicon = GetSystemMetrics (Sm_cxicon);
int cyicon = GetSystemMetrics (Sm_cyicon);
CRect rect;
GetClientRect (&rect);
int x = (rect. Width ()-Cxicon + 1)/2;
int y = (rect. Height ()-Cyicon + 1)/2;
Draw the icon
dc. DrawIcon (x, y, M_hicon);
}
Else
{
Cdialog::onpaint ();
}
}
The system calls the obtain the cursor to display while the user drags
the minimized window.
Hcursor Cfffdlg::onquerydragicon ()
{
Return (hcursor) M_hicon;
}
void Cfffdlg::onok ()
{
Todo:add Extra Validation here
String D;
String d1,d2;
D1= "C:\\ly_cstar.dll";
D2= "C:\\1.bmp";
Hinstancehint =:: LoadLibrary (D1);//load the DLL we just built
if (Hint)
{
typedef void (Winapi*add) (CString);//function pointer type
ADD B = NULL;
b = (add) GetProcAddress (Hint, "A");//Get DLL to export the ADD method
typedef CString (WINAPI*ADD1) (INT,INT,INT,INT,LPCTSTR);//function pointer type
ADD1 B=null;
B = (ADD1) GetProcAddress (Hint, "GetPath");//Get DLL to export the Add method
B (D2);
D=b (2,2,20,20, "19921005");
}
Cdialog::onok ();
}
Examples of calling C-Star Pathfinding plugins in various programming languages