Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles
(untagged)

Login: Automation Client

0.00/5 (No votes)
4 Sep 2003 1  
An automation client that connects to the automation server for verifying user ID and password.

Introduction:

We have learned what automation is and created a login management automation server. Now it's time to build a client application for that server to be more meaningful. You may be guessing why so much work has been done for just reading and writing a simple database, but now you will understand the benefits of this automation technique.

Once you build an automation server, to incorporate it in any client application, its just a simple task of few minutes. The automation server once built, can be used for different client applications built over different environments, without much changes. This would also isolate the client application from the dirty job of long database programming, creating a middle tier between the client application and your database. Further, if you make changes in the database structure, you will just have to change the automation server on the remote server, leaving the client application on all the machines unchanged. This also provides an easy technique for remote database management through DCOM (Distributed Component Object Model).

Prerequisite:

This tutorial assumes that you are familiar with Visual C++/MFC, COM, Automation and other technologies used in this tutorial like ADO, etc. Though there is no need to understand their underpinnings in great detail, you should at least have a working knowledge of what these underpinnings mean. Most important of all, you should take a glance over the login automation server example.

Implementation:

Now it's time to do some hands with DevStudio. We would create an automation client with the help of the type library created by the automation server example.

  • Create a dialog based MFC project unselecting everything in step 2 of 4 and accepting the default values for everything else.
  • Open the class wizard and create a new class from the type library, browse to the folder where the login.tlb file is located and select it.

    Confirm Classes

  • Include the remotelogin.h file to dialog class implementation.
  • Create the dialog as shown in the figure.

    Confirm Classes

  • Add a member variable m_login of type IRemoteLogin to the dialog class.
  • Add the following lines in the OnInitDialog() member function of the dialog class.
    CoInitialize(NULL);
    if(!m_login.CreateDispatch("Login.CRemoteLogin"))
        AfxMessageBox("Login.CRemoteLogin Not found");
  • Link the buttons with dialog member functions and implement these functions as done in the sample project.
  • Compile the project now, it should compile without any errors and then run it.

Conclusion

Here we have successfully built an automation client that can verify the user ID and password, allowing us to add new user, remove existing user and edit the user information. This client can be easily created in MFC, as you have seen how easy it was to connect to a remote automation server. We can use the remote objects created with the help of the type library, just as other objects created from some other classes. Your valuable suggestions are always welcome, to make this article better.

What Next

Learn how to extend your automation component over network via the use of DCOM, here.

Copyright

This code is provided "as is" with no expressed or implied warranty. You can use and abuse this code without any restriction. If you use this source code in any commercial product, acknowledgment is not required but would be appreciated.

Bibliography:

  • VC++, COM and Beyond.

    Author: Yashavant Kanetkar & Sudesh Saoji.

    ISBN: 81-7635-206-8

    Publisher: BPB Publications.

    User Level: Beginning-Intermediate.

    This book provides an in-depth coverage of cutting edge technologies like Document/View Architecture, OLE, COM, DCOM, ActiveX, Open GL, Printing and Print Previewing, HTML Help System, Programming the disk and Screen Savers.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here