Visualizzazione dei risultati da 1 a 9 su 9
  1. #1

    c++ problema esporta dati dll

    grazie a "oregon" son riuscito a creare il codice per comunicare vb.net e una dll ma adesso viene il bello questo e il codice che vorrei funzionasse

    //
    #include "stdafx.h"
    //
    extern char* prova="";
    //
    extern "C" __declspec(dllexport) char* Testo()
    {
    //
    return prova;
    //
    }
    //
    void main(void)
    {
    //
    prova="bb";
    //
    }
    //
    se io metto il valore di prova dentro extern "C" tutto funziona il fatto che e che voglio potere aggiornare il valore di prova dalla main o da funzioni esterne da qualunque parte del codice anche perche tutto questo si aggiornera spesso.

  2. #2
    Utente di HTML.it L'avatar di oregon
    Registrato dal
    Jul 2005
    residenza
    Roma
    Messaggi
    36,465

    Re: c++ problema esporta dati dll

    Originariamente inviato da darkrurik
    grazie a "oregon" son riuscito a creare il codice per comunicare vb.net e una dll ma adesso viene il bello questo e il codice che vorrei funzionasse



    se io metto il valore di prova dentro extern "C" tutto funziona il fatto che e che voglio potere aggiornare il valore di prova dalla main o da funzioni esterne da qualunque parte del codice anche perche tutto questo si aggiornera spesso.
    Non è che il problema sia chiaro, la variabile dovresti dichiararla, ad esempio

    char prova[200];
    ed utilizzarla dove vuoi.

    Il fatto che ci sia un main poi, non è affatto chiaro, dato che parliamo di una DLL.
    No MP tecnici (non rispondo nemmeno!), usa il forum.

  3. #3
    questo e il codice della libreria x intero:


    //
    #include "stdafx.h"
    #include "DDO_text_in.h"
    #include <windows.h>
    #include <iostream>
    #include <cstring>
    #include <cstdio>
    #include <cstdlib>
    #include <fstream>
    #include <strstream>
    #include <stdio.h>
    #include <iomanip>
    #include <string>
    #include <sstream>
    #include <algorithm>
    #include <time.h>
    #include <sys/timeb.h>
    #include <wchar.h>
    #include <sstream>
    #include <stdio.h>
    #include <string.h>
    #include <stdlib.h>
    #include <winsock.h>
    //
    using namespace std;
    //
    BEGIN_MESSAGE_MAP(CsampleApp, CWinApp)
    END_MESSAGE_MAP()
    //
    #define PLUGIN_UNIQID "CSLLLYPS"
    //
    #define MAX_STRING 256
    //
    //char* prova;
    extern int mia_var=10;
    extern char* prova="";
    //
    CsampleApp::CsampleApp()
    {
    // construction
    }
    //
    CsampleApp theApp;
    //
    void __cdecl cfbot_plugininformation(CFBOT_PLUGININFORMATION *info)
    {
    //
    strcpy(info->uniqid, PLUGIN_UNIQID); // 8 chars UNIQUE ID + \0 as a line end
    info->pluginversion = CF_BOT_VERSION(0, 4);
    info->desired_botversion = CF_BOT_VERSION(3, 94);
    //
    _tcscpy(info->authors, _T("DARKRURIK plugin DDO_text_in"));
    _tcscpy(info->email, _T("mailto:rurik@supereva.it"));
    _tcscpy(info->http, _T("http://www.darkrurik.com"));
    _tcscpy(info->plugindescription, _T("DARKRURIK version plugin DDO_text_in"));
    //
    }

    int __cdecl cfbot_initialize(CFBOT_CALLBACKS *callbacks, char *path, void *context)
    {
    //
    CopyMemory(&theApp.host, callbacks, sizeof(CFBOT_CALLBACKS));
    theApp.context = context;
    //
    theApp.host.cfbot_subscribe(theApp.context, PLUGIN_UNIQID, CF_BOT_IM_EVENTS);
    theApp.host.cfbot_subscribe(theApp.context, PLUGIN_UNIQID, CF_BOT_ROOM_EVENTS);
    //
    return 1;
    //
    }
    //
    const char* convertToAscii(const TCHAR *rawString)
    {
    const std::wstring ws(rawString);
    std::string s(ws.begin(), ws.end());
    s.assign(ws.begin(), ws.end());
    return s.c_str();
    }
    //
    wchar_t* ConvertToWideChar(char* p)// function which converts char to widechar
    {
    wchar_t *r;
    r = new wchar_t[strlen(p)+1];

    char *tempsour = p;
    wchar_t *tempdest = r;
    while(*tempdest++=*tempsour++);

    return r;
    }
    //
    void Testo_ROOM(_tstring t_data)
    {
    _bot_exchange_format f;
    _tstring nickname = (_tstring)f[0x01];
    _tstring text = (_tstring)f[0x02];
    BYTE attributes = (BYTE)f[0x03];
    BYTE size = (BYTE)f[0x04];
    DWORD color = (DWORD)f[0x05];
    DWORD effects = (DWORD)f[0x06];
    BYTE charset = (BYTE)f[0x07];
    BYTE pitch = (BYTE)f[0x08];
    std::string font = (std::string)f[0x09];

    _bot_exchange_format p(PLUGIN_EVENT_ROOM_TEXT); //PLUGIN_EVENT_ROOM_TEXT); //PLUGIN_EVENT_IM);
    p << _bot_value(0x01, t_data);
    p << _bot_value(0x02, attributes);
    p << _bot_value(0x03, size);
    p << _bot_value(0x04, color);
    p << _bot_value(0x05, effects);
    p << _bot_value(0x06, charset);
    p << _bot_value(0x07, pitch);
    p << _bot_value(0x08, font);

    std::string d = p.data();
    theApp.host.cfbot_pushevent(theApp.context, PLUGIN_UNIQID, (char *)d.data(), d.size());

    }
    //
    void Comando_ROOM(char *event_data, int event_size)
    {
    _bot_exchange_format f;
    if (f.receive(std::string(event_data, event_size)))
    {
    switch(f.pid)
    {
    case BOT_EVENT_ROOM_TEXT: //Comandi dentro la Box di Yesto Principale
    {

    _tstring nickname = (_tstring)f[0x01];
    _tstring text = (_tstring)f[0x02];
    BYTE attributes = (BYTE)f[0x03];
    BYTE size = (BYTE)f[0x04];
    DWORD color = (DWORD)f[0x05];
    DWORD effects = (DWORD)f[0x06];
    BYTE charset = (BYTE)f[0x07];
    BYTE pitch = (BYTE)f[0x08];
    std::string font = (std::string)f[0x09];
    if (text.length() > 0)
    {
    _tcsupr((TCHAR *)text.c_str());
    if (!_tcscmp(text.c_str(), _T("!V")))
    {

    }
    }
    } break;
    }
    }
    }
    //
    /* Funzione Somma */
    extern "C" __declspec(dllexport) short Somma(short a, short b)
    {
    return a+b;
    }
    //
    extern "C" __declspec(dllexport) char* Testo(char* c, char* r)
    {
    //
    return prova;
    //
    }
    //

    void __cdecl cfbot_pushevent(char *event_data, int event_size)
    {
    //
    _bot_exchange_format f;
    if (f.receive(std::string(event_data, event_size)))
    {
    switch(f.pid)
    {
    case BOT_EVENT_ROOM_IN:
    {
    //
    //
    } break;
    case BOT_EVENT_ROOM_TEXT:
    {
    //
    _tstring nickname = (_tstring)f[0x01];
    _tstring text = (_tstring)f[0x02];
    BYTE attributes = (BYTE)f[0x03];
    BYTE size = (BYTE)f[0x04];
    DWORD color = (DWORD)f[0x05];
    DWORD effects = (DWORD)f[0x06];
    BYTE charset = (BYTE)f[0x07];
    BYTE pitch = (BYTE)f[0x08];
    std::string font = (std::string)f[0x09];
    //
    //
    } break;
    case BOT_EVENT_ROOM_OUT:
    {
    //
    //
    } break;
    }
    }
    //
    }

    void __cdecl cfbot_finalize(void)
    {
    // finalize plugin
    }

    void __cdecl cfbot_display_settings(void)
    {
    //
    AfxMessageBox(_T("Settings window is not available for this plugin"), MB_OK | MB_ICONINFORMATION);
    //
    }
    //
    BOOL CsampleApp::InitInstance()
    {
    //
    CWinApp::InitInstance();
    //
    return TRUE;
    //
    }

    ecco adesso ai tutto

    dentro al codice qui sotto vorrei passare la variabile nickname
    naturalmente la converto prima in char* e la vorrrei passare a
    extern "C" __declspec(dllexport) char* Testo(char* c, char* r)

    cosi da esportare il valore del nikname a vb.net

    void __cdecl cfbot_pushevent(char *event_data, int event_size)
    {
    //
    _bot_exchange_format f;
    if (f.receive(std::string(event_data, event_size)))
    {
    switch(f.pid)
    {
    case BOT_EVENT_ROOM_IN:
    {
    //
    //
    } break;
    case BOT_EVENT_ROOM_TEXT:
    {
    //
    _tstring nickname = (_tstring)f[0x01];
    _tstring text = (_tstring)f[0x02];
    BYTE attributes = (BYTE)f[0x03];
    BYTE size = (BYTE)f[0x04];
    DWORD color = (DWORD)f[0x05];
    DWORD effects = (DWORD)f[0x06];
    BYTE charset = (BYTE)f[0x07];
    BYTE pitch = (BYTE)f[0x08];
    std::string font = (std::string)f[0x09];
    //

    //
    } break;
    case BOT_EVENT_ROOM_OUT:
    {
    //
    //
    } break;
    }
    }
    //
    }

  4. #4
    Utente di HTML.it L'avatar di oregon
    Registrato dal
    Jul 2005
    residenza
    Roma
    Messaggi
    36,465
    Ma questa è un'applicazione, non una libreria DLL ... di che stiamo parlando?
    No MP tecnici (non rispondo nemmeno!), usa il forum.

  5. #5
    no no e il codice della dll

  6. #6
    Utente di HTML.it L'avatar di oregon
    Registrato dal
    Jul 2005
    residenza
    Roma
    Messaggi
    36,465
    Ma che tipo di DLL è ?

    E scusa, dato che l'autore risulti tu (siamo sicuri?) come mai non sai come intervenire?
    No MP tecnici (non rispondo nemmeno!), usa il forum.

  7. #7
    allora no lautore non sono io comprando un bot di una chat video ti danno questo codice che crea la dll per gestire il bot e tanti con questa appunto fanno dei programmi di vario genere io appunto voglio prendere tutti i nick e passarli al vb,net

  8. #8
    io voglio solo passare dei valori dalla dll al vb.net

  9. #9
    infatti in c++ non sono un grann programmatore allora volevo passare tutto su vb.net per questo che ci sto lavorando

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2024 vBulletin Solutions, Inc. All rights reserved.