Controlling calls to subroutines from VB straight from AutoCAD Command prompt

Discussion in 'AutoCAD' started by matt_1ca, Feb 9, 2005.

  1. matt_1ca

    matt_1ca Guest

    Does anyone know how I can call a subroutine from VB instead of from VBA.

    Right now what I can do is run the vb exe file from the command line which normally opens up the exe's form from which I can run various functions by clicking button from said form etc.

    But on top of that I also need to be able to do something like a (vl-vbarun mysubroutineNameHere) from the command prompt to be able to make calls to the certain specific VB routines.

    Right now the only option I can think of is create a .dll and reference it from vba which is no problem -- but what I want is to be able to do it straight from VB instead so that I do not have to regsvr32 on all machines that will try to run my program.

    Thanks for all the kind help you can give on this matter.

    Matt
     
    matt_1ca, Feb 9, 2005
    #1
  2. matt_1ca

    fantum Guest

    You could pass command line arguments to your VB app, check for them in Sub Main(), and call your subroutines from there. BTW, you don't need regsvr32 - you can call the DllRegisterServer function exported by any ActiveX dll.
     
    fantum, Feb 9, 2005
    #2
  3. I've only ever seen that done as a hard-coded declaration. Do you know
    of a more dynamic method?
     
    Frank Oquendo, Feb 9, 2005
    #3
  4. matt_1ca

    fantum Guest

    If you don't know the name of the dll until run-time then you'll have to duplicate the functionality of regsvr32: LoadLibrary to load the dll, GetProcAddress to get a pointer to the function, then call the function pointer. I recommend Mathew Curland's Advanced Visual Basic 6 for detailed instructions.
     
    fantum, Feb 9, 2005
    #4
  5. Hi,

    The easiest solution to this type of problem is to create an install for
    your program with a product like Inno Setup which enables you to register
    all the DLLs with the installation.

    --

    Regards,


    Laurie Comerford
    www.cadapps.com.au
     
    Laurie Comerford, Feb 9, 2005
    #5
  6. matt_1ca

    matt_1ca Guest

    Thank you, this looks like one possible solution.

    I can see a potential problem though -- and the reason is that I am looking at making the user only have to call the program once -- like on startup of AutoCAD. The program will automatically open up.

    Then it will be like a toolbar that stays up there -- so the solution you mentioned can work but it does not look like its going to be in that kind of scenario where I do not have to go doing Shell or ShellExecute to the .exe file which also erases all the values of global variables everytime.

    Matt
     
    matt_1ca, Feb 10, 2005
    #6
  7. matt_1ca

    matt_1ca Guest

    I think I can work around the potential problem I mentioned -- thank you for the brilliant concept you have shared.

    Matt
     
    matt_1ca, Feb 11, 2005
    #7
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.