#1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2002
    Posts
    0
    Rep Power
    0

    Question Opening ODBC DSN Admin


    I'm new to Visual C++ and would like to know if there is a way to open the ODBC data source administrator from a button in a dialog box. Or to open an arbitrary .exe from a VC++ app in general cause I know the Admin can be opened using c:\WINNT\System32\odbcad32.exe on a Windows 2000 box. Any hints would be much appreciated!
  2. #2
  3. /(bb|[^b]{2})/

    Join Date
    Nov 2001
    Location
    Somewhere in the great unknown
    Posts
    5,163
    Rep Power
    792
    to execute any command that you would do from the command line can be done with the system() function.
    It should be in the stdlib.h header.
    i.e.
    Code:
    #include <stdlib.h>
    
    int main () {
        return system("c:\WINNT\System32\odbcad32.exe");
    }
  4. #3
  5. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2002
    Posts
    0
    Rep Power
    0
    Thanks sooooooo much...don't know how many days I went searching on the net for that. So simple too. Problem now is...I'm using Visual C++ and calling the function when a button is pressed:

    void CDBManager::OnOdbc()
    {
    system("c:\\WINNT\\System32\\odbcad32.exe");

    }

    This works great except that a DOS window also opens behind the ODBC Data Source Admin window for the cmd.exe system call. Know how to prevent this or close it?
  6. #4
  7. /(bb|[^b]{2})/

    Join Date
    Nov 2001
    Location
    Somewhere in the great unknown
    Posts
    5,163
    Rep Power
    792
    No, not right off hand, you might want to search msdn about how to get an applications handle. I know it is possible, but just don't remember all the specifics about it. But you would get the cmd windows handle and then you can close it.
  8. #5
  9. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2002
    Posts
    0
    Rep Power
    0

    Smile


    For anyone else who is interested, you can also use:

    HWND screen = ::GetDesktopWindow();

    ShellExecute(screen, "open", "c:\\WINNT\\System32\\odbcad32.exe", NULL, NULL, SW_SHOWNORMAL);

    And there is no DOS window displayed. Thanks for everyone's help!!

IMN logo majestic logo threadwatch logo seochat tools logo