Introduction

The MicroStation Development Library (MDL) and MicroStationAPI provide APIs for developers wanting to create custom applications for MicroStation® from Bentley Systems. We create a MicroStation application as a DLL, written using C++ and built with the Microsoft C++ compiler and linker provided with Visual Studio.

When editing your source code, you can choose whether to use Microsoft Visual Studio, Microsoft Visual Studio Code, or one of your favourite text editors.

When building your app, you can use Visual Studio or the Bentley Systems make (bmake) tools.

Windows Application Association

Q How do I open a file using the application associated with its extension in Windows?

A If you're writing a .NET application, then life is simple! Use System.Diagnostics.Process.Start(fileName).

A If you're writing C++, then use the Win32 function ShellExecute(). This examines the Windows' registry to find the application associated with a file extension. You can specify various parameters that modify how the application starts and how it displays a document. Visit MSDN and search all topics to find more information.

I've wrapped the function as shown below. It passes MicroStation's native window handle, but that's not essential.

void DisplayFileWithDefaultViewer (const char* path, const char* file)
{
	HWND		hWnd;
	mdlWindow_nativeWindowHandleGet (&hWnd, mdlDialog_overallTitleBarGet (), HANDLETYPE_HWND);
	HINSTANCE hInst = ::ShellExecute (hWnd,
            nullptr,            //	Verb, e.g. 'open'		
            file,               //	Document to open		
            nullptr,            //	Params if executable	
            path,               //	Default directory		
            SW_SHOWNORMAL);     //	Window display mode		
}

The example above was implemented in a C++ DLL.

Return to MicroStationAPI articles index.

Questions

Post questions about C++ and the MicroStationAPI to the MicroStation Programming Forum.