Tengo un programa de consola en C++ que funciona perfectamente, pero para utilzarlo desde VB.NET me vendria mejor crear una .dll
¿Como podria hacerlo?
¿Como podria hacerlo?
Esta sección te permite ver todos los mensajes escritos por este usuario. Ten en cuenta que sólo puedes ver los mensajes escritos en zonas a las que tienes acceso en este momento.
Mostrar Mensajes Menúusing std::string;
using std::cout;
using std::endl;
cout << endl << L"INFO: begin_pos: " << begin_pos;
cout << endl << L"INFO: end_pos: " << end_pos;
wprintf(L"\nINFO: Nombre del perfil: ", extract);
int size = 1000;
std::string text(profBuffer, profBuffer+ size);
std::string begin_text("<name>");
std::string end_text("</name>");
size_t begin_pos = text.find(begin_text) + begin_text.length();
size_t end_pos = text.find(end_text);
std::string extract = text.substr(begin_pos,end_pos);
const char* NombrePerfil = extract.c_str();
std::cout << NombrePerfil << std::endl;
std::string extract = text.substr(begin_pos,end_pos);
std::string extract = text.substr(begin_pos,end_pos-begin_pos);
UINT status = ERROR_SUCCESS;
WCHAR profBuffer[WPA_API_MAX_BUFFER_SIZE] = {0};
HANDLE wlanHandle = 0;
GUID interfaceGuid = {0};
DWORD wlanResult = 0;
status = WlanGetProfile(wlanHandle, &interfaceGuid, 0, profBuffer, NULL, TRUE, NULL, &wlanResult);
wprintf(profBuffer);
int size = 2000;
std::string text(profBuffer, profBuffer + size);
// define what we're looking for
std::string begin_text("<name>");
std::string end_text("</name>");
// find the start and end of the text we need to extract
size_t begin_pos = text.find(begin_text) + begin_text.length();
size_t end_pos = text.find(end_text);
wprintf(L"\nINFO: begin_pos: ", begin_pos);
wprintf(L"\nINFO: end_pos: ", end_pos);
// create a substring from the positions
std::string extract = text.substr(begin_pos, end_pos);
//test that we got the extract
wprintf(L"\nINFO: Nombre del perfil: ", extract);
Dim Cadena As String = XmlProfile
Dim Delimitador_Ini As String = "<name>"
Dim Delimitador_Fin As String = "</name>"
Cadena = Split(Cadena , Delimitador_Ini, , CType(CompareMethod.Text, Microsoft.VisualBasic.CompareMethod))(1)
Cadena = Split(Cadena , Delimitador_Fin, , CType(CompareMethod.Text, Microsoft.VisualBasic.CompareMethod))(0)
Label1.Text = "Nombre del perfil: " & Cadena
Cita de: ivancea96 en 24 Abril 2015, 11:48 AM
En primer lugar, size es siempre 0. Tendrás que poner ahí el tamaño de la cadena.
Cita de: ivancea96 en 24 Abril 2015, 11:48 AMEn segundo lugar, pon esta linea en sustitucion de la antigua:std::string extract = text.substr(begin_pos,end_pos-begin_pos);
Cita de: ivancea96 en 24 Abril 2015, 11:48 AMEn tercer lugar, en caso de que quieras agarrar todos los datos, tal vez te interese crear un método para leer un xml y guardarlo ordenadamente, eso ya como veas.
<?xml version="1.0"?>
<WLANProfile xmlns="http://www.microsoft.com/networking/WLAN/profile/v1">
<name>NombrePerfil</name>
<SSIDConfig>
<SSID>
<hex>75775657685794438794</hex>
<name>NombrePerfil</name>
</SSID>
</SSIDConfig>
<connectionType>ESS</connectionType>
<MSM>
<security>
<authEncryption>
<authentication>WPA2PSK</authentication>
<encryption>AES</encryption>
<useOneX>false</useOneX>
</authEncryption>
<sharedKey>
<keyType>passPhrase</keyType>
<protected>false</protected>
<keyMaterial>1234567890</keyMaterial>
</sharedKey>
<keyIndex>1</keyIndex>
</security>
</MSM>
</WLANProfile>
int size = 0;
wchar_t* Perfil = profBuffer;
std::string text(Perfil, Perfil + size);
// define what we're looking for
std::string begin_text("<name>");
std::string end_text("</name>");
// find the start and end of the text we need to extract
size_t begin_pos = text.find(begin_text) + begin_text.length();
size_t end_pos = text.find(end_text);
// create a substring from the positions
std::string extract = text.substr(begin_pos,end_pos);
// test that we got the extract
wprintf(L"\nINFO: Nombre del perfil: ", extract);