Click here to Skip to main content
Click here to Skip to main content
Go to top

Login: Automation Client

, 4 Sep 2003
Rate this:
Please Sign up or sign in to vote.
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, along with any associated source code and files, is licensed under The GNU General Public License (GPLv3)

Share

About the Author

Priyank Bolia
Software Developer (Senior)
India India
No Biography provided

Comments and Discussions

 
QuestionGood but What Purpose ??? Pinmemberkokosan16-Apr-07 6:13 
AnswerRe: Good but What Purpose ??? PinmemberPriyank Bolia16-Apr-07 19:23 
Generalhelp Pinmembervijin0512-Oct-06 2:22 
Generalhelp Pinmemberbadboy74127-Jul-05 9:53 
GeneralRe: help PinmemberPriyank Bolia27-Jul-05 18:45 
GeneralRe: help Pinmemberbadboy74128-Jul-05 17:43 
GeneralNot Updating the database PinmemberAnand Kumar30-Sep-03 0:21 
GeneralRe: Not Updating the database PinmemberPriyank Bolia3-Oct-03 4:19 
Generalerror while running the client application PinsussAnanymous21-Sep-03 21:21 
GeneralRe: error while running the client application PinmemberPriyank Bolia23-Sep-03 20:01 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Mobile
Web04 | 2.8.140916.1 | Last Updated 5 Sep 2003
Article Copyright 2003 by Priyank Bolia
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid