This commit is contained in:
softland 2018-10-17 20:14:33 +03:00
Родитель 1227bbe9c0
Коммит 3760b5cfc1
3 изменённых файлов: 54 добавлений и 50 удалений

Просмотреть файл

@ -1,4 +0,0 @@
PACKAGE := $(shell go list)
GOOS := $(shell go env GOOS)
GOARCH = $(shell go env GOARCH)
OBJ_DIR := $(GOPATH)/pkg/$(GOOS)_$(GOARCH)/$(PACKAGE)

Просмотреть файл

@ -1,15 +1,23 @@
golang library get AutoCAD parameters
golang library get AutoCAD parameters from registry
functions:
1. func IsAutocadInstalled() bool
IsAutocadInstalled Checks installed in system any version of AutoCAD
return true if installed,
return false if not istalled
use const _REG_PATH_ACAD_ == `Software\Autodesk\AutoCAD`
1.
func IsAutocadInstalled() bool
//IsAutocadInstalled - checks installed in system any version of AutoCAD
// return true if installed,
// return false if not istalled
// used const _RegPathAcad === `Software\Autodesk\AutoCAD`
2. func ReleaseAutocadInstalled() string
ReleaseAutocadInstalled return string with release of AutoCAD installer in system
return "-" if Autocad not installed
2.
func ReleaseAutocadInstalled() string
//ReleaseAutocadInstalled return string with release of AutoCAD installer in system
//return "-" if Autocad not installed
3.
func RegPathAutocadLogFile() string
//RegPathAutocadLogFile - return string registry path to key store log file folder
4.
func PathAutocadLogFile() string
//PathAutocadLogFile - return path to folder where AutoCAD store log file
3. func PathAutocadLogFile() string
PathAutocadLogFile - return string to path of log file

Просмотреть файл

@ -5,39 +5,21 @@ import (
)
const (
_RegPathAcad = `Software\Autodesk\AutoCAD`
_RegPathEditorConfAcadR15 = `Software\Autodesk\AutoCAD\R15.0\ACAD-201:409\Profiles\<<Unnamed Profile>>\Editor Configuration`
_RegPathEditorConfAcadR16 = `Software\Autodesk\AutoCAD\R16.0\ACAD-201:409\Profiles\<<Unnamed Profile>>\Editor Configuration`
_RegPathEditorConfAcadR19 = `Software\Autodesk\AutoCAD\R19.0\ACAD-B001:409\Profiles\<<Unnamed Profile>>\Editor Configuration`
_RegPathEditorConfAcadR22 = `Software\Autodesk\AutoCAD\R22.0\ACAD-2001:409\Profiles\<<Unnamed Profile>>\Editor Configuration`
_RegPathEditorConfAcadR23 = `Software\Autodesk\AutoCAD\R23.0\ACAD-2001:409\Profiles\<<Unnamed Profile>>\Editor Configuration`
_RegPathAcad = `Software\Autodesk\AutoCAD`
_RegPathAcadEditor = `\Profiles\<<Unnamed Profile>>\Editor Configuration`
_RegLogFilePath = "LogFilePath"
)
//TAcadVersion - struct for store version
type TAcadVersion struct {
ver string
name string
path string
}
var _AcadVersion = [...]TAcadVersion{
{"-", "-", "-"},
{"AutoCAD 2000", "15.0", _RegPathEditorConfAcadR15},
{"AutoCAD 2013", "19.0", _RegPathEditorConfAcadR19},
{"AutoCAD 2018", "22.0", _RegPathEditorConfAcadR22},
{"AutoCAD 2019", "23.0", _RegPathEditorConfAcadR23},
}
//IsAutocadInstalled Checks installed in system any version of AutoCAD
//IsAutocadInstalled - checks installed in system any version of AutoCAD
// return true if installed,
// return false if not istalled
// use const _REG_PATH_ACAD_ == `Software\Autodesk\AutoCAD`
// used const _RegPathAcad === `Software\Autodesk\AutoCAD`
func IsAutocadInstalled() bool {
_, err := registry.OpenKey(registry.CURRENT_USER, _RegPathAcad, registry.QUERY_VALUE)
return (err == nil)
}
//ReleaseAutocadInstalled return string with release of AutoCAD installer in system
//ReleaseAutocadInstalled - return string with release of AutoCAD installer in system
//return "-" if Autocad not installed
func ReleaseAutocadInstalled() string {
key, err := registry.OpenKey(registry.CURRENT_USER, _RegPathAcad, registry.QUERY_VALUE)
@ -53,40 +35,58 @@ func ReleaseAutocadInstalled() string {
return s
}
//PathAutocadLogFile - return string to path of log file
func PathAutocadLogFile() string {
//RegPathAutocadLogFile - return string registry path to key store log file folder
func RegPathAutocadLogFile() string {
if !IsAutocadInstalled() {
return "-"
return ""
}
path := _RegPathAcad
key, err := registry.OpenKey(registry.CURRENT_USER, path, registry.QUERY_VALUE)
if err != nil {
return "-"
}
defer key.Close()
if err != nil {
return ""
}
s, _, err := key.GetStringValue("CurVer")
if err != nil {
return "-"
return ""
}
path = path + "\\" + s
key, err = registry.OpenKey(registry.CURRENT_USER, path, registry.QUERY_VALUE)
if err != nil {
return "-"
return ""
}
s, _, err = key.GetStringValue("CurVer")
if err != nil {
return "-"
return ""
}
path = path + "\\" + s
key, err = registry.OpenKey(registry.CURRENT_USER, path, registry.QUERY_VALUE)
if err != nil {
return "-"
return ""
}
return path + "\\Profiles\\<<Unnamed Profile>>\\Editor Configuration"
return path + _RegPathAcadEditor
}
//PathAutocadLogFile - return path to folder where AutoCAD store log file
func PathAutocadLogFile() string {
s := RegPathAutocadLogFile()
if s == "" {
return ""
}
key, err := registry.OpenKey(registry.CURRENT_USER, s, registry.QUERY_VALUE)
if err != nil {
return ""
}
s, _, err = key.GetStringValue(_RegLogFilePath)
if err != nil {
return ""
}
return s
}