Click here to Skip to main content
Click here to Skip to main content

Login: Automation Client

By , 4 Sep 2003
 

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)

About the Author

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

Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
You must Sign In to use this message board.
Search this forum  
    Spacing  Noise  Layout  Per page   
QuestionGood but What Purpose ???memberkokosan16-Apr-07 6:13 
I don't the reason why this article is posted ???

 
I am kokosan

AnswerRe: Good but What Purpose ???memberPriyank Bolia16-Apr-07 19:23 
The article was posted way back to explain COM/DCOM.
 

Generalhelpmembervijin0512-Oct-06 2:22 
when i compile the client program the remotelogin.h file is not getting created.please help
Generalhelpmemberbadboy74127-Jul-05 9:53 
can someone send my the file becasue i dont have a clue to what to do if you can just send me the file and all the stuff i need to badboy54321@mail.com , i want to put it on my FTP server . thanks.
GeneralRe: helpmemberPriyank Bolia27-Jul-05 18:45 
badboy741 wrote:
send my the file becasue i dont have a clue
 
Didn't get you. Please be more clear, what you want to say.
 
http://www.priyank.in/
GeneralRe: helpmemberbadboy74128-Jul-05 17:43 
can you send me the login client because i dont get a clue to how to make it.
GeneralNot Updating the databasememberAnand Kumar30-Sep-03 0:21 
Client application is running correctly without displaying the error when i am adding the user, the database is not updating, what could be the problem.
i want to debug the server app. to know wheather the function is being called or not , how can i do this.
thanks in advance.
GeneralRe: Not Updating the databasememberPriyank Bolia3-Oct-03 4:19 
Hi,
Sorry, I could not figure out the exact solution, but you may try to run the client and server on the same machine, with the .mdb file in the same folder as the server and check the path of the .mdb file in the program too, add some message boxes code at various places in the functions in the server, and then call the server from the client agian, you may see the message boxes to confirm that the function are really calling. Then if the database is not updating then the problem may be the databse driver or the database location. I hope this may work for you.
BYE!
 
http://www.geocities.com/priyank_bolia/

 

Generalerror while running the client applicationsussAnanymous21-Sep-03 21:21 
Login : CRemoteLogin Not found error while running the application, try to sort this.
GeneralRe: error while running the client applicationmemberPriyank Bolia23-Sep-03 20:01 
I think that you haven't installed the server program firstly, before running the client. Read the server article at : http://www.codeproject.com/useritems/automationserver.asp
 
http://www.geocities.com/priyank_bolia/

 

Questiondatabase location ?memberJOHN1131-Aug-03 0:12 
Hi,
 
Its about your articles : Login: Automation Client/server
 
The database location should not be hard coded since it may change. I suggest to add a property to the server reflecting the database location (.MDB).
 
GOOD articles.
AnswerRe: database location ?memberPriyank Bolia31-Aug-03 21:09 
Sir, You check the server program again, I have used the GetSystemDirectory() API and a installer, to make the server more better, You can always change that location, with some more programming as shown by this method.
 
http://www.geocities.com/priyank_bolia/

 

AnswerRe: database location ?sussAnonymous8-Nov-03 18:17 
hjjjghj jhgjhgj jghjhgj hjghjghj jgh jghgh hjghjghj ghjghjghjhgjgh ghjhjhg

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

Permalink | Advertise | Privacy | Mobile
Web01 | 2.6.130619.1 | Last Updated 5 Sep 2003
Article Copyright 2003 by Priyank Bolia
Everything else Copyright © CodeProject, 1999-2013
Terms of Use
Layout: fixed | fluid