In the previous few lectures, we explained some of the basic knowledge of the API. Are you still thinking about what to do with your hands? Don't worry about this, we will explain some in-depth examples. 3721 network real name believe everyone I have used it. Have you ever thought about adding this feature in your own program? The heart is not as good as action, we still have to try it. First download the 3721 network real name SDK. This place has download: http: //download.net. com.cn/html/010142001030703.html. It is a compressed package. After unlocking, we can first check some documents in the doc directory. From China, we have learned that there are two types of 3721 network real name SDK, one is Based on the ActiveX control, the other is based on dynamic call mode. The previous method only needs to register it with regsvr32.exe, and then use the same use as other controls in VB. We mainly explain the latter method.
Open CNSTD.DLL API.txt We can see some of the function prototypes, parameters, and function descriptions in cNStd.dll. It contains 3 API functions, listed below: 1, BOOL __STDCALL ISCNS (Char * PCNS); 2, Void __stdcall convertcns2url (char * purl, int nuclenu); 3, void __stdcall openurl (char * purl); from the literal we understand the three functions of the three functions. Now we have to do it It is converted to the API function statement, and its statement should be as follows:
Public Declare Function IsCNS Lib "CNSTD.DLL" (ByVal pCNS As String) As BooleanPublic Declare Sub ConvertCNS2URL Lib "CNSTD.DLL" (ByVal pCNS As String, ByVal pID As String, ByVal pURL As String, ByVal nURLLen As Long) Public Declare Sub OpenURL LIB "CNSTD.DLL" (ByVal Purl AS String)
After knowing the API declaration, we start writing our program. Open the VB6 new project. Add the module file, and write the above API function declaration to the module file. We place the following control on Form1. The property settings are as follows: form1: borderstyle = 1 'Fixed Single Caption = "Network Real Name Test" Command2: CAPTION = "Open (& O)" Enabled = FalseTextBox2: TextBox1: Text = "3721" Command1: CAPTION = "Conversion (& T)" Label2: CAPTION = " URL: "Label1: CAPTION =" Please enter the Chinese URL: "Add the following code: Private submmand1_click () Dim Str As Stringstr = Space $ (255) if iF iscns (text1.text) THEN CALL CONVERTCNS2URL (Text1.Text," TEST ", STR, 256) text2.text = str command2.enabled = trueElse text2.text =" Can't find the Chinese URL "Command2.enabled = false IFEND SUB