Ah! Jinshan Words' Latex Reading Procedures Completed! After two days of fighting this weekend, I finally completed a Jinshan word library reading process! Of course, there were 2 European Cups in the middle, and the wife played a few tank wars, otherwise it can be completed faster! Motivation for this program has been a long time, because it is always backing English words, if there is a complete English language, you can do a lot of things, such as finding a word similar words, window, widow, wind, etc.. Naturally, this word library wants to get out of our Jinshan word. First of all, I went to Google, I got a word library of Jinshan, it seems that there is no ready-made fruit, obviously the word library file is also encrypted. So I can only write a program yourself, and the unit Kingsoft will not find me! :) When I wrote this article, the progress of reading the word has completed about 70% (341500/457550 words). In fact, there are some ready-made English word speakers. In the sample program of the book "STL Tutorial and Reference Guide", there is a word library named DICTION, but only 20160 words, and now, I will soon I will There is a 457550 word word library. OK, I will share this process with you. Development Platform: Visual C 6.0 My Language Library Reading Thought is: Running Jinshan Word 2003, getting its handle in the program, and then reading the child window handle of the word list, then, hehe! Read all the contents in the list. IT Sounds Good, Let's Go Now! 1: Create a dialog program, enumerate all sub-windows under desktops, which is the main window of the program, the window title contains "Jinshan Words", which is the main master of Jinshan. Window; Similarly, enumerate its sub-window, the window title contains "WordList" (can be used to use SPY tracking), which is the word list control. Description: Later, it will be better, and should look for a word list control based on the window ID.
CString strText; CWnd * pWndCiba = CWnd :: GetDesktopWindow () -> GetWindow (GW_CHILD); while (pWndCiba) {pWndCiba-> GetWindowText (strText); TRACE ( "% s [% x] / n", strText, pWndCiba- > GetSafehWnd ()); if ("STRText.Find (" Jinshan Words ")! = -1) Break; // Did NOT FIND WINDOW, GET NEXT WINDOW IN LIST. PWNDCIBA = PWNDCIBA-> getWindow (GW_HWndNext);} IF pWndCiba == NULL) return; CWnd * pWndWordList = pWndCiba-> GetWindow (GW_CHILD); while (pWndWordList) {pWndWordList-> GetWindowText (strText); TRACE ( "% s [% x] / n", strText, pWndWordList-> GetSafehWnd ()); if (strText.isempty ()) Break; if ("WordList")! = -1) Break; // DID NOT FIND WINDOW, GET Next Window in list. PWndwordList = PWNDLIST-> GetWindow (GW_HWndNext);} if (pWndwordList-> getsafehwnd () == null) Return; 2: It seems that the work has been completed, then call the following code: int ncount = pwordList-> getItemcount (); get the return value is 457550, this is the total number of words in the word library 3: The problem has appeared! Then prepare to try to read the first word of the list, is "a", using the following code: char PText [256]; listview_getitemtext (PWndWordList.getsafehWnd (), 0, 0, ptext, 255); Result ... Jinshan word Crash, Windows crashes! Perhaps the windowsxp called never crash is not finished. In short, I can only use Power on the keyboard to shut down, this is also a lot of action before success. :( 4: Where is the problem? In fact, we must blame our own procedures that have not been written during the process.
ListView_getitemtext () This macro, is actually a message that sent LVM_GETITEMTEXT, returns text by the list of received messages; however, char PText [256]; is the memory allocated in my program, how can I use the Jinshan Words? ! Later, I also tried this method: hglobal hglobal = Globalalloc (GPTR, 256); char * ptext = (char *) Globalock (hglobal); listview_getitemtext (PWndWordList-> getsafehwnd (), 0, 0, ptext, 255) GlobalUnlock (Hglobal); GlobalFree (Hglobal); there is no solving problem: GlobalAlloc () allocated memory is indeed available for different processes, but Hglobal, ie memory space handles should be delivered, and then received by the received message Program call GlobalLock () converts HGlobal to a local memory pointer, apparent that Kingsoft will not give us this task. If you use other processes to share data, such as Shared Memory Files, there is a problem that must be processed by the message recipient. So what should I do? ? ? 5: Since we can't use the process of sharing data between processes, we change your ideas, let our program run in the process space of Jinshan Wangeon! This will not need to consider the problem of sharing data between processes. Very lucky, there is a method called a DLL injection process to be implemented. You can go to Google "Injecting A DLL INTO ANOTHER Process's Address Space" or find LoadDll.exe in the MSDN, and my program is based on this example. Briefly introduce the LoadDLL project because I have no exact research. There is actually 2 projects, Loaddll, which is a very simple command line program, usage as follows: loaddll.exe / l 3448 TestLib.dll TestFunction / L indicates that the ID of the process to be injected into the DLL, can Use Task Manager to get testlib.dll represents a function name of one of the export functions in the loaded DLL TestFunction DLL to remove the DLL from the process using loaddll.exe / u 3448 testlib.dll. 6: Loaddll I didn't change, I have modified TestFunction in Testlib.dll, and the function is overridden. First, copy the code to the window handle in step 1, very unfortunate, because TestLib.dll cannot use MFC, so I can only modify the version of SDK. Then, call listview_getitemtext (HWndWordList, 0, 0, PTEXT, 255); HWndWordList is a list window handle. Start running, is it big me? Back in PTEXT is "1234567890123456789012345678901234567890"! My god, why? ! I tried to read the second line, the first line, and the result was the same. So I modified this code and read my own program that contains the list, and reads the list of lists. It seems that the problem is in the word list of Jinshan Words.
When the article is close to the end, the reading program is finally running! It takes near to 1 hour and 15 minutes! It doesn't matter, I don't plan to improve again, as long as I caught my mouse, it is a good cat! 7: Use the Spy to track the word list window again, and find that there is a LVS_OWNERDATA style, which is a virtual list. In fact, it must be, otherwise more than 400,000 lines, use ordinary lists, display speed can be more beautiful than the turtle or its brothers. I guess: 1) The virtual list cannot be accessed using the LVM_GETITEMTEXT or LVM_GETITEM message. This guess 99% is wrong because the MSDN does not contain these two in the message that the virtual list cannot be used. Limited to time, I didn't test the virtual list control of other programs. 2) Kingsoft to prevent others from doing this, shield these 2 messages. It seems that there is no other interface to access it, is it Subclass list control? Because I am not familiar with SDK programming, I also give up the test. Because, I decided to recruit! Using a very rude and rogue method, I have succeeded! Description: About the virtual list control, you can find "Virtual List Controls" or "Maxum" in the MSDN. 8: After observing the use of Jinshan Wangeon, it is found that after selecting a word in the list, the ComboBox above the interface will display the word, and the window on the right will display the explanation of the word. That's right, my method is to read the content in ComboBox. After testing, CAPTION in ComboBox is a word. So how do you read all words? We can get all words all words, you can get all words. Code is as follows: nCount = ListView_GetItemCount (hWndWordList); // get item count nPrevIndex = ListView_GetNextItem (hWndWordList, -1, LVIS_SELECTED); for (nIndex = 0; nIndex