Home > Software engineering >  VB6.0 by use call DLL how to declare the following two functions
VB6.0 by use call DLL how to declare the following two functions

Time:09-21

Call DLL file, saw any callback function, novice don't know how to write a statement, a great god to help me

CodePudding user response:

Don't be A language code is modified to B language code busywork,
Also don't use A language code to directly invoke B language code base, this complicated things so easy to get wrong,
Just make A, B language code of input and output is redirected to A text file, or modify A, B language code let it through text file input and output,
Can easily make A, B coordination between the two languages,
For example:
A will request data written to A file a.t xt, renamed after finish aa. TXT
B find aa. TXT, read its contents, call the corresponding function, and writes the results file b.t xt, after finish delete aa. TXT, changed its name to bb. TXT
Found A bb. TXT, read the content, after finish delete bb. TXT
Above can be replaced by any kind of A language or development environment, B can be replaced by any kind of with the development of A different language or development environment,
Unless A or B does not support to determine whether A file exists, file read and write and file name,
But who can name does not support to determine whether a file exists, file read and write and file name for the development of language or development environment?
Can put the temporary files on the RamDisk efficiency decrease wear disk,
Data structure is very complex, a text file format problems refer to a json or XML

The communication methods between the temporary text file sharing this process there are plenty of advantages, compared to other method only listed below I can think of now:
Loose coupling between process,
Can be on the same machine, process, also can cross machine, across the operating system, hardware platform, and even multinational,
, convenient debugging, and monitoring, only let the third party or artificial view the temporary text files,
Switch, convenient online service, need to delete or create the temporary text files,
, is convenient to realize distributed and load balancing,
Services to provide convenient, queue, queue is full and it is almost impossible to happen (unless the hard disk space full)
DE...

"Across different languages, machine, across the operating system, hardware platform, multinational, cross *. *" misery,
Back is "the use of Shared a plain text file information communication" of the shore!

CodePudding user response:

Zhao four repeater upstairs this reply, look at sick!!!!!!!!!!!



 '1: API function declaration 
Private Declare Function OpenSDK_AllocSession Lib "XXX. DLL" (ByVal pHandle As Long, _
ByRef pUser As Any, _
ByRef pSession As Long, _
ByRef iSessionLen As Long, _
Optional ByVal bSync As Boolean=False, _
Optional ByVal iTimeOut As Long=& amp; HEA60 & amp;) As Long
'parameters description:
'pHandle your "callback" address, when using the incoming: AddressOf OpenSDK_MessageHandler
'pUser you to "callback" message data, can be arbitrary (according to you need to define) "custom types,"
'can also be a "standard" in VB6 data types, if you don't need to transfer data, can be passed ByVal 0 & amp; ,
'pSession pointed to a string data, estimation is ANSI format code, using CopyMemory () the data copied to a word
'section in the array, reoccupy StrConv () function converts UTF16 code strings,
'iSessionLen from on a parameter (pSession) toward the memory address, the character data of how many bytes,
'bSync slightly
'iTimeOut "synchronization" of the "timeout" parameters, unit of time in milliseconds, the default value is 60000 ms (1 minute),




'second: you want to achieve "the callback function", must be written in a "standard module"
Public Sub OpenSDK_MessageHandler (ByVal szSessionId As Long, ByVal iMsgType As Long, _
ByVal iErrorCode As Long, ByVal pMessageInfo As Long, _
ByVal pUser As Long)
'parameters description:
'see szSessionId pSession, just don't have "data length data," according to SessionId format, select a
'" the maximum length of a byte array, use CopyMemory () the data copy, after converted to string,
"Find" vbNullChar "position, truncation, and from there
'pUser VB6 "own the function of" parameter types cannot be Any, if it is a Long value, can be used directly,
'if it is other types (including a custom data types), can define a variable of the appropriate type, and then use the
'CopyMemory () to copy pUser pointing to the data in the corresponding variables, the length of the copy is variable data
'type the number of bytes, if it is "custom types, and members include dynamic arrays, string type
'members, had better use ZeroMemory after use () to the variable "empty", there are: the string into a
'member had better not assigned to a new value, dynamic array not to redefine size can change values) when (element is not string,
'if "no need", just ignore this parameter directly,
'
'this function (the callback) other parameters there is no need to say more,
'
End Sub

CodePudding user response:

More disgusting solution, maybe more spirit,
Refer to the "Apollo 13"

CodePudding user response:

That according to you this dog P logic:
DLL is almost entirely in the operating system of c + + development, so many computer languages, the value of the didn't exist! Can only use c + + development software?
What VB6 also cannot be used to develop this specific application, can be used to have a "calculator" of what, just do addition, subtraction, multiplication, and division?

CodePudding user response:

Someday, Chen8013 can fall into the pit of A language B language,
  •  Tags:  
  • API
  • Related