le passage de paramètre échoue dans une application managée
bonjour,:D
J'ai un problème d'intégrité de données.
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
| erc CWfStream::getline( FILE* pFile, System::String^ sLine)
{
int len;
wchar_t sTemp[80];
try
{
std::fgetws( sTemp, 80, pFile);
sLine = gcnew String( sTemp);
len = sLine->Length;
if( len > 0)
{
return( 0);
}
else
{
if( CWfStream::eof() != false)
return( 1);
else
return( -1);
}
}
catch(...)
{
//throw Doc_exception("erreur dans le getline", 0);
}
} |
dans cette méthode la valeur de sline est "[ServerInformation]", ce qui est consistant
mais au retour dans l'appelant la valeur est "";
Comment ce fait il qu'un handler System::String^ ne vive pas au delà de la méthode
Je vous met le code de l'appelant:
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
| //A variable to hold the fetched line in String format
System::String^ sLine;
//A variable to hold the position of the searched character
unsigned int iPos;
bool b_noMoreLine = false;
bool b1,b2;
//If the INI file is not open then return FAILURE
if (!CWfStream::is_open())
{
return FAILURE;
}
//Move the file pointer to the beginning of the file
CWfStream::seekg(0);
//Loop till the end of the file
b1 = CWfStream::eof() != true;
b2 = b_noMoreLine != true;
while( b1 && b2)
{
size_t len;
int iStatus;
//Get a line from the file
iStatus = CWfStream::getline( pFile, sLine);
const wchar_t* chars = (const wchar_t*)(Marshal::StringToHGlobalUni( sLine)).ToPointer();
wchar_t* tmp = (wchar_t*)chars;
Marshal::FreeHGlobal( IntPtr( (void*)chars)); |
c'est la méthode getline qui ne renvoi pas le paramètre sLine.
celui qui me répondra sera :ccool: