Automatic installation of the hottest AutoCAD seco

2022-10-01
  • Detail

Automatic installation and processing of AutoCAD secondary development program

the secondary development of AutoCAD mainly involves the following contents: first, use low-speed loading (1) to write various user-defined functions and form several lisp, ARX, vlx or ads files, as well as some DCL files. (2) To establish a menu file that meets your own requirements, you can generally add your own content to the original AutoCAD menu file. For the AutoCAD2000 version, you can also add some menu files, and then add them to the system interactively. (3) Add some contents to the P or similar files of the system for various initialization operations, such as loading some files immediately at startup. (4) Set some paths through the system dialog box. After the successful development of the program, these operations are installed and applied to other AutoCAD systems. Especially when a large number of installations are required, a lot of tedious work such as file retrieval, content addition and deletion, subdirectory creation, file copy, system setting, etc. will be carried out. If the above work can be carried out automatically, and the whole secondary development program can be embedded into the system without human intervention, the work efficiency will be greatly improved. Therefore, the author developed an automatic installation program with vc++, so that the manual operation that originally required five or six minutes can be completed automatically in more than ten seconds

first, basic ideas

the whole installation program follows the following ideas:

1) first obtain the installation path of the AutoCAD2000 system of the machine you are on

2) find the menu file AutoCAD2000 support u, open the file and add the content to the end

3) look for the LISP file AutoCAD2000. Pay attention to turn off the main motor source support acad200 dynamometer. If the device tilts to the right, the included angle between the vertical line of the toothed bar and the push rod will increase P. open the file and add the content to be added to the end

4) create a pre named subdirectory and copy all kinds of files formed by secondary development

5) give an information box to inform the installation of success, and if there is a problem, inform the installation of failure

it should be pointed out that the content added to p must have the following statements:

(command "u menu" (strcat (getvar "menuname") ".Mnu")), in order to forcibly execute the menu file loading command and compile and load the changed u file

in addition, there is an assignment statement in the content added to P, which assigns a global variable to the full path name of the subdirectory containing all the secondary development generated files to be created for the secondary development program to call when needed, thus avoiding the trouble of setting the path interactively in the AutoCAD environment

The trouble of setting the path interactively in the environment of

II. Implementation mode and key functions

in order to obtain the installation path of AutoCAD2000, we need to use the relevant functions of the windows system registry

first open the registry through the RegOpenKey function:

hkey HKEY

LONGret=RegOpenKey( HKEY_LOCAL_MACHINE, "Software\Autodesk\AutoCAD\R14.0\ACAD-1:804" ,

where the first parameter HKEY LOCAL - machine is the predefined primary key handle in the registry, the second parameter is the sub key content under HKEY LOCAL machine in the registry, and the third parameter HKEY will return a sub key handle for the next key value query. If the function runs successfully, it will return a long integer error success

next, use the regqueryvalueex function to query the key value:

dword dwtype=reg_ SZ;

BYTE szData[100];

DWORD dwSize=sizeof(szData);

If (ret=ERROR_SUCCESS)

ret=RegQueryValueEx(hKey, "AcadLocation", 0, &dwType, szData, &dwSize);

the first parameter HKEY is the subkey handle to be queried obtained by RegOpenKey function; It is a topic worthy of concern. The second parameter "acadlocation" is the name of the key value to be queried; The third parameter is reserved, and it is required to add 0; The fourth parameter is the key value data type; The sixth parameter is the key buffer capacity; The key is the fifth parameter szdata, which will bring back the result of the key value to be queried. This key value is the required installation path of AutoCAD2000

the relationship between the primary key, sub key, key value name and key value in the registry mentioned above can be found by the windows series registry through the following methods: click "start" -- "run" -- "add" regedit "--" OK "--" HKEY "local" machine "--" software "--" Autodesk "--" AutoCAD "--" r15.0 "--" acad-1:804 "--" acadlocation "--" e:autocad2000 ". The key value corresponding to the key value name "acadlocation" is "e:autocad2000", which is the installation path of AutoCAD2000. The content may be different on different machines

The

key value query function will return a long integer error success if it runs successfully

char szRootName[100]=\support\u;

if (ret=ERROR_SUCCESS)

1strcat((char*) szData, szRootName);

now the full path of u is installed in szdata. The following operations will open the file and add content:

handle hfile=createfile ((char*)) szdata, generic_ READ|GENERIC_ WRITE, 0,

NULL, OPEN_ EXISTING, FILE_ ATTRIBUTE_ NORMAL, NULL);

if (hfile! =invalid_handle_value)

{

if (0xFFFFFF! =setfilepointer (hfile, 0, null, file_end))

{

char szbuf[1000]= "n**pop12n**camn[&cam]n[-> basic parameters]n[chuck origin] ^c^cchucku datamn[tool change origin] ^c^ctool_datamn[tool management]n create new tool ^c^ccreateu newu tooln[

Copyright © 2011 JIN SHI