The younger brother pretty good, really don't understand, please help to see and appreciate
Cipher. CPP
# include "stdafx. H"
# include "Cipher. H"
BOOL APIENTRY DllMain (HMODULE HMODULE,
DWORD ul_reason_for_call,
LPVOID lpReserved
)
{
The switch (ul_reason_for_call)
{
Case DLL_PROCESS_ATTACH:
Case DLL_THREAD_ATTACH:
Case DLL_THREAD_DETACH:
Case DLL_PROCESS_DETACH:
break;
}
Return TRUE;
}
__declspec (dllexport) string __stdcall compress_wireless (string STR)
{int j, k, g, resend_buf [MAX_PACK_SIZE], wireless_buf [MAX_PACK_SIZE];
The static string array [MAX_PACK_SIZE], compress_data1, compress_data2;
Unsigned int compress_data;
For (unsigned int I=0; i<=STR. Length (); I +=3) {
G=I/3;
Array [g]=STR. Substr (I, 2); }
For (int h=0; H<=14; H++) {
Stringstream ss_1;
Ss_1 & lt;Ss_1 & gt;> Wireless_buf [h];
Ss_1. STR (" ");
}
for(j=0; J<15. J++)
Resend_buf [1 + j]=wireless_buf [j];
for(j=0; J<14. J++) {
compress_data=https://bbs.csdn.net/topics/wireless_buf [j] * 0 x100 + wireless_buf [j + 1);
If ((compress_data & amp; 0 x8000)!=0)
compress_data=https://bbs.csdn.net/topics/((compress_data/0 x100) ^ 0 x89) * 0 x100 + compress_data % 0 x100;
For (k=0; k<8; K++) {
Compress_data & lt; <=1;
If ((compress_data & amp; 0 x8000)!=0)
compress_data=https://bbs.csdn.net/topics/((compress_data/0 x100) ^ 0 x89) * 0 x100 + compress_data % 0 x100;
}
Wireless_buf [j + 1)=compress_data/0 x100;
}
For (k=0; k<7. K++) {
Compress_data & lt; <=1;
If ((compress_data & amp; 0 x8000)!=0)
compress_data=https://bbs.csdn.net/topics/((compress_data/0 x100) ^ 0 x89) * 0 x100 + compress_data % 0 x100;
}
Compress_data & lt; <=1;
Stringstream ss_2;
Ss_2 & lt;Ss_2 & gt;> Compress_data1;
Compress_data2=compress_data1. Substr (0, 2);
The transform (compress_data2. The begin (), compress_data2 end (), compress_data2. The begin (), towupper);
Return compress_data2;
}
Cipher. H
# pragma once
# include "targetver. H"
# include "stdafx. H"
#include
#include
#include
#include
#include
#include
using namespace std;
# define WIN32_LEAN_AND_MEAN
# define MAX_PACK_SIZE 20
# ifdef CIPHER_EXPORTS
# define CIPHER_API __declspec (dllexport)
# the else
# define CIPHER_API __declspec (dllimport)
# endif
//this is from the Cipher. DLL export
__declspec (dllexport) string __stdcall compress_wireless (string STR);
Cipher. Def
LIBRARY Cipher
EXPORTS compress_wireless
VB calls
Option Explicit
Private Declare Function compress_wireless Lib "C: \ Users/Administrator/Desktop/Cipher \ Debug \ Cipher DLL" (ByVal p As String) As String
Private Sub Command1_Click ()
Dim STR As String
STR=compress_wireless (80, 66 a, 99 b "28 a 0 0 0 0 0 0 0 d d d d d d d 00 0")
Text1.. Text=STR
End Sub
Private Sub Text1_Change ()
End Sub
CodePudding user response:
Feel you in VB API function type declaration is not correct,From Cipher. CPP code line 22, I think the API returns a value of "first address pointer string",
So in VB6 should put the function return value statement for Long,
Then, according to return a pointer to the value directly, direct Copy "MAX_PACK_SIZE" bytes of data to a Byte array,
//definition of data types:
The static string array [MAX_PACK_SIZE], compress_data1, compress_data2;
//API return:
Return compress_data2;
If this "return data" are valid ASCII characters,
Can use Strconv () function converts it from a Byte array into a string, and then assigned to the TextBox control,
CodePudding user response:
Collapsed in the pop-up dialog box, press the corresponding button to enter debugging press Alt + 7 key to view the Call Stack, namely "the Call Stack" from the inside to the following out of from the inner to outer function Call history, double-click a row to the cursor to the Call of the source code or assembly instruction, don't understand when double click on the next line, until we can read ,CodePudding user response:
The vc interface function of all string into a char * try