1. Summary of memory release issues of member structures containing pointers
When a Member with a pointer in the struct allocates memory to the struct, it needs to calculate the total amount of memory occupied by these member variables for allocation. If it is missing, a release error occurs, in addition, the assignment must correspond to the sequence of member variables one by one.
2. When VB calls vc dll, the system prompts that error 53 is not found in the file.
Your DLL file may also depend on some other files,
For example, some C/C ++ runtime libraries. If some DLL dependent files cannot be found, this error may also be reported.
3. Precautions for transferring the struct value of VB to VC DLL
(1) The definition of struct member variables in VB must be one-to-one with those in VC. Otherwise, an error occurs when passing values.
(2). Return the running results in VC (stored in a struct). When retrieving the results, VB must pay attention to the corresponding memory space. The VC string ends with/0.
4. conversion of Chinese character codes of VB and VC (premise: VB stores Chinese character information returned from VC in byte arrays. If VB Chinese character strings do not solve this problem, the Chinese character strings can be directly returned)
The Chinese character display of VC uses GB code, while the Chinese character string uses Unicode code in VB
Therefore, vc needs to convert the result string returned by Chinese characters to a unicode code to display it normally in VB. You only need to call the API: strconv
For example:
Struct definition:
'Struct definition: <br/> Public type h_rtudataaly <br/> cphonevalue (20) As byte <br/> crtuinfo (20) As byte <br/> cgprs (10) as byte <br/> end type <br/> strphonevalue = strconv (rtudata. cphonevalue, vbunicode) 'gb code to Unicode code
In another case, conversion is not required:
For example: dim strresult as string * 20 remember to define the char * whose length corresponds to VC. In addition, note: strcpy is used to assign values to char *.
5. Storage of log files
If the current directory needs to exist, if the directory does not exist, you must first create a directory and then create a file. The relative path representation of VC :. /log/2.txt current directory .. /log/2.txt the parent directory of the current directory.
For example:
Cfile myfile; <br/> createdirectory ("log", null); // create a folder in the current directory <br/> myfile. open (". /log/2.txt", cfile: modecreate | cfile: modereadwrite | cfile: modenotruncate); // create if no data exists
6. Mutual conversion between ctime and cstring
Cstring-> ctime: <br/> ctime tmdatestart (atoi (strdate. mid (0, 4), atoi (strdate. mid (4, 2), atoi (strdate. mid (6, 2), 0, 0); // start time <br/> ctime-> cstring: <br/> strdate = tmtemp. format ("% Y-% m-% d ");
7. Obtain the current directory in VC ++
//************************************** * ************* // <Br/> // function description: obtain the current path <br/> // parameter: <br/> // return value: <br/> // Author: <br/> // time: 2010.04.16 <br/> //********************************* * **************** // <br/> cstring c#fun:: fungetpath () <br/>{< br/> cstring g_szcurpath; <br/> // obtain the current path <br/> cstring szcurpath (""); <br/> getmodulefilename (null, szcurpath. getbuffer (max_path), max_path); <br/> szcurpath. releasebuffer (); <br/> g_szcurpath = szcurpath. left (szcurpath. reversefind ('//') + 1); </P> <p> return g_szcurpath; <br/>}< br/> 8. cstring and char * Conversion <br/> cstring-> char *: <br/> char * = (lpstr) (lpcstr) cstring; <br/> char *-> cstring: <br/> cstring = char * <br/>