my application, written in delphi 7, sends commands autocad activex. works fine of customers, in rare cases cannot communicate autocad , reports error invalid class string
(autocad application running ok). error pops after line:
acadv := getactiveoleobject('autocad.application');
i have searched problem lot, not find working solution.
the small console application below shows how check name of automation object registered in windows registry. automation objects need have registry entry in order can invoke them name in autocad.application
note isregistered
function below not guarantee able access object using createoleobject/getactiveoleobject however, if expected name not found there amiss, may able fix re-installing automation objects software.
program checkregconsole; {$apptype console} uses sysutils, windows, registry; function isregistered(const classstring : string) : boolean; var reg : tregistry; begin result := false; reg := tregistry.create(key_read); try reg.rootkey := hkey_classes_root; result := reg.keyexists(classstring); reg.free; end; end; var s : string; begin s := 'word.application'; // ms word s := 'acroexch.pddoc'; // adobe acrobat document if isregistered(s) writeln(s + ' registered') else writeln(s + ' not registered'); readln; end.
btw, in (limited) experience, getactiveoleobject not succeed when ought to. if fails, may worthwhile trying createoleobject instead.
there book delphi programmers called "delphi com programming" eric harmon, if can hold of copy, , there countless automation tutorials on internet. see e.g. https://msdn.microsoft.com/en-us/library/windows/desktop/ms221375(v=vs.85).aspx ms take on subject.
Comments
Post a Comment