When invoking AutoCAD through interop, how to to find current installed AutoCAD program ID - autocad

I am using interop and within a console application launching CAD as per the following example. How can I find the programID of AutoCAD which is installed on my local machine.
For example in the below article it uses
const string progID = "AutoCAD.Application.17.1";
https://through-the-interface.typepad.com/through_the_interface/2007/12/launching-autoc.html

Try just using "AutoCAD.Application" with no specific reference. Works for me.
Your issue is going to be the reference to the proper version of AutoCAD though. I get around this by using late binding.
Pretty good information on Late Binding
Not really sure that this is kept up to date -->
AutoCAD Version List

Related

Has anyone here gotten the DJI Windows SDK to work yet?

As the https://developer.dji.com/windows-sdk/ is now available, I thought I might have a go.
However, so far I have not gotten anything in VisualStudio using C# that references either the DJIWindowsSDK.dll, DJIWindowsWrapper.dll or DJIWindowsWrapper.winmd to work.
I have tried console applications on the .NET Framework and .NETCore, but so far all I get when just trying to either get at var droneManager = DJISDKManager.Instance; or trying to set any callback on DJIWindowsWrappedInterfaces are compile errors about mismatched platform settings (MSIL vs x32 or x64) or System.BadImageFormatException on first access to any SDK code.
Anyone have any idea on what type of projects these assemblies are actually meant to be usable? Documentation only describes classes and methods and such (which seem clear enough, in general), not basic nitty gritty stuff like the type of projects and platform settings supported.
And I have so far not gotten the SampleCode to work. It's nice that the sample code seems (if I look at source code) to be a sort of complete set of code showing SDK functions at work, but it only seems to work with the latest version of Windows 10, the Windows 10 SDK, and VisualStudio. And possibly a ton of other prerequisites, which do not seem all to clearly spelled out at all.
I would like to get a most simple kind of Hello World! style example (from some kind of Console app) working (first), but so far I'm not succeeding..
Have you checked the DJI Windows SDK Github Readme? I think the Get Started Immediately part can help you run the sample code. It lists the prerequisites, and necessary steps to run it.
BTW, I just found this documentation, you can take a look and see if it helps: https://github.com/dji-sdk/Windows-SDK-Doc/blob/master/source/application-development-workflow/workflow-integrate.md

How can I construct and interact with a dynamic (ActiveX) dialog using OLE on Windows?

I have looked at the Microsoft Forms 2.0 Object Library (FM20.DLL) and Microsoft Windows Common Controls (comctl32.dll), as both exist (I think) as OLE providers on my system. (I am doing this by opening them in VBA in Excel to look at the libraries with their members) and playing around with them in VBA.
My bigger problem is that I don't understand the relationship between the libraries themselves and ActiveX - how do I know which members can be created as ActiveX objects? (For example, you can create "Excel.Application", but not "MSForms.UserForm").
I want to be able to script (using OLE) a form using some library, display it, respond to events, etc. I would prefer using something that is already available (like the libraries mentioned above, if possible) to prevent having to install extra software.
If you can give an example (in any language) to get me started, that would be very helpful and much appreciated.
As per HansPassant's comment, what worked is using MS Forms 2.0, which has an ActiveX object, "Forms.Frame.1", which can be created and used in my program.
I found a program called ActiveXHelper, which allows one to see all the registered ActiveX objects on the system.

Get Product Version from Product Code in C#

I need to find the product version of an installed application using the product code GUID. Is there a way to do this using a simple API call of some sort? I have found ways to do it using P/Invoke and the WindowsInstaller namespace, but I am trying to avoid using P/Invoke.
The Windows Installer exposes Win32 API functions (P/Invoke) as you have discovered. It also has COM automation interfaces that wrap these APIs but I'm sure you can guess is this is even less elegant. Windows Installer XML (WiX) Deployment Tools Foundation (DTF) has an MSI interop library that wraps it as managed code but I'm sure you can guess what it's doing under the covers: P/Invoke.
There are ways of getting it from the registry but this is not the official API and is less elegant IMO.
So to answer your question, you are already doing it in a very good and professional way.
If you want to get sneaky you can look through the registry to figure it out. When an MSI is installed windows creates a set of registry keys under:
HKLM\Software\Microsoft\Windows\CurrentVersion\Uninstall\<munged-ProductCode>
or
HKLM\Software\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\<munged-ProductCode>
(depending on your machine/MSI bitness)
Under that registry location there should be a registry value named "ProductVersion". The trick is to know how to 'munge' a windows GUID (see http://www.vmwareinfo.com/2011/09/surgically-eliminating-windows.html).

Adding a DLL file as reference in C#.NET project

I am currently working on a project to perform disk defragmentation in Microsoft Windows environment. For that I want to use the in-built functions of the Windows defragmentation utility. I read somewhere that Windows uses "dfrgres.dll" file to perform defragmentation. So, I want to add "dfrgres.dll" file as a reference in my project. But I am not able to do so. This is the error message which I am getting when I try to add the specified DLL into my project:
"A reference to '...\dfrgres.dll' could not be added. Please make sure that the file is accessible, and that it is a valid assembly or COM component"
Please tell me where the problem is...or is there any other way to do it...??? Are there any other open source resources available over the internet for defragmentation...???
Regards,
Mr. Elusive
There is no dedicated DLL or COM server to perform defrag, the low-level interface uses IOCTL codes to talk to the device driver. Briefly described here.
There's a Microsoft employee blog post that proposes a C# interface. No idea if it still works on later versions of Windows.

searching VB6 code

I've inherited a ASP/VB6 code base (not my forte... yet) and I'm trying tease it apart to figure out the cause on an error message I'm receiving when running the app.
I've traced it back through an event that is being raised in on of my classes. Is there away in windows I can search the bulk of the code base for where it is being consumed?
Ctrl-F (and selecting Current Project) has not sufficed.
The linux geek in me is saying dump it to a insert distro box and just grep for the sucker. But there's got to be some way in the IDE to do it... right?
But there's got to be some way in the IDE to do it... right?
No. There are some plugins for the IDE, such as the MZ Tools that might help. Otherwise, just use the find tool from the Windows command line. Not nearly as comfortable as using grep, of course.
If you have any new version of VS (2003,5,8) installed, just use the "Find in Files" feature and point it at the VB6 folders.
Other than that, most "notepad" replacements (textpad, notepad+) offer a "Find in Files" as well.
Check out http://www.mztools.com/index.aspx
MZ-Tools 3.0 is a freeware add-in for Visual Basic 6.0, Visual Basic 5.0 and the Visual Basic For Applications editor.
It is essential for anyone still working with VB 6.0
It has an enhanced find feature as well as a calling Procedure similar to .net Find usage.
I have a large legacy code-base in VB6 which needs maintenance from time to time and I have used Microsoft Desktop Search on my local copy to help find variable and method names across the code files.
Also Grep is available for Windows.

Resources