Click here to Skip to main content
Licence 
First Posted 1 Dec 2004
Views 22,551
Downloads 554
Bookmarked 12 times

Network Message

By | 1 Dec 2004 | Article
Netsend message in LAN

Introduction

This application is used as net send message in Windows. This application retrieves all the usernames in LAN into a listbox and user can select any username and sendmessage. By this application, no need to remember all the usernames in LAN.

void CNetworkDlg::DisplayUsers()
{
    m_list.ResetContent();
    nUsers=0;
        CString str;
    
    struct HostInfo
    {
        char *csName;
        char *csAdr;
        char *csComment;
    };
    struct hostent *host;
    struct in_addr *ptr;    
    DWORD dwScope = RESOURCE_CONTEXT;
    NETRESOURCE *NetResource = NULL;
    HANDLE hEnum;
    WNetOpenEnum(dwScope, NULL, NULL, NULL, &hEnum);
    WSADATA wsaData;
    WSAStartup(MAKEWORD(2,2),&wsaData);
    UINT item = 0;
    if (hEnum)
    {
        DWORD Count = 0xFFFFFFFF;
        DWORD BufferSize = 2048*8;
        LPVOID Buffer = new char[2048*8];
        
        WNetEnumResource(hEnum, &Count, Buffer, &BufferSize);
        
        NetResource = (NETRESOURCE*)Buffer;
        
        char szHostName[200];
        
        for (UINT i = 0; i < BufferSize/sizeof(NETRESOURCE); 
                                            i++, NetResource++)
        {
            if (NetResource->dwUsage == RESOURCEUSAGE_CONTAINER 
                && NetResource->dwType == RESOURCETYPE_ANY)
            {
                if (NetResource->lpRemoteName)
                {
                    CString strFullName = NetResource->lpRemoteName;
                    
                    char buf[512];
                    
                    if (0 == strFullName.Left(2).Compare("\\\\"))
                        strFullName = 
                          strFullName.Right(strFullName.GetLength()-2);
                    m_list.AddString(strFullName);
                    nUsers++;                                        
                }
            }
            WNetCloseEnum(hEnum);
        }    
        WSACleanup();
        CString st;
        st.Format("Total Users:%d",nUsers);
        SetDlgItemText(IDC_STATIC1,st);
                }
}

History

  • 2nd December, 2004: Initial post

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

About the Author

Eswar_Illuri

Web Developer

India India

Member

I am working at Virinchi Technologies as programmer in vc++,COM & symbian c++. My hobbies are painting, and play chess and carams.

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. (secure sign-in)
 
Search this forum  
 FAQ
    Noise  Layout  Per page   
  Refresh
GeneralUI for net send PinsussMsftone23:09 21 Jan '05  
GeneralHI Eswar PinmemberThatsAlok19:21 3 Dec '04  
GeneralFull Progam PinsussAnonymous2:54 2 Dec '04  
GeneralBody of article does not match the subject PinmemberDavidCrow8:17 2 Dec '04  

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.

Permalink | Advertise | Privacy | Mobile
Web02 | 2.5.120517.1 | Last Updated 2 Dec 2004
Article Copyright 2004 by Eswar_Illuri
Everything else Copyright © CodeProject, 1999-2012
Terms of Use
Layout: fixed | fluid