Network programming in VC++ .NET
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2

Thread: Network programming in VC++ .NET

  1. #1
    Join Date
    Oct 2005
    Posts
    19

    Question Network programming in VC++ .NET

    Iím practicing network programming in C++ .Net. I figured a simple yahoo messenger login application would be a fun way to do this. Every example online is written in Visual Basic. I cannot find anything pertaining to yahoo chat, written in C++.

    I found a really good example written in VB .NET which works. The example utilizes a .dll file for encrypting the username and password when logging into yahoo messenger. Below it the Visual Basic example of this function prototype.

    #Region "Private Externally Referenced Functions"
    Private Declare Function YMSG12_ScriptedMind_Encrypt Lib "YMSG12ENCRYPT.DLL" (ByVal username As String, ByVal password As String, ByVal Seed As String, ByVal result_6 As String, ByVal result_96 As String, ByVal intt As int32) As Boolean
    #End Region
    This is my attempt at recreating this in C++.Net. I make a bogus call to the ďYMSG12_ScriptedMind_EncryptĒ function for testing purposes only.

    #include "stdafx.h"
    #include "Form1.h"
    #include "login.h"
    #include <windows.h>
    #include <string.h>
    #include <iostream>

    using namespace YAHOOLOGINC;
    using namespace std;

    typedef bool (WINAPI*cfunc)(std::string username, std::string password,
    std::string Seed, std::string result_6,
    std::string result_96, int intt);

    cfunc YMSG12_ScriptedMind_Encrypt;

    [STAThreadAttribute]
    int main(array<System::String ^> ^args)
    {
    // Enabling Windows XP visual effects before any controls are created
    Application::EnableVisualStyles();
    Application::SetCompatibleTextRenderingDefault(false);

    HINSTANCE hMod = LoadLibrary("YMSG12ENCRYPT.DLL");
    if(hMod==NULL)
    MessageBox::Show("Unable to load dll");

    YMSG12_ScriptedMind_Encrypt=(cfunc)GetProcAddress((HMODULE)hMod, "YMSG12_ScriptedMind_Encrypt");
    //test call to the dll
    bool test = YMSG12_ScriptedMind_Encrypt("hdhd", "dgdf", " ", " ", " ", 7);

    // Create the main window and run it
    Application::Run(gcnew Form1());
    return 0;
    }
    When I run this code I get this error
    An unhandled exception of type 'System.AccessViolationException' occurred in YAHOOLOGINC++.exe

    Additional information: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.

    Iím not sure if this .dll can be used in a C++ app or if this has something to do with the CheckForIllegalCrossThreadCalls being set to true by defualt in VS 2005

    I have attached a copy of this .dll file (YMSG12ENCRYPT.dll) and the VB.NET example.
    Last edited by Brad Jones; June 26th, 2014 at 10:19 AM.

  2. #2
    Join Date
    Sep 2000
    Location
    Indianapolis
    Posts
    6,421

    Re: Network programming in VC++ .NET

    Attachments were flagged by safety scan, so removed.

    Admin
    -----------------------------------------------
    Brad! Jones, CodeGuru.com Site Director
    Developer.com Network Director / EiC

    webmaster@codeguru.com
    (My Latest Book)


    -----------------------------------------------

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Azure Activities Information Page

Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center