Click here to Skip to main content
15,902,275 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Creating new buttons (and let them do something) Pin
wielklem11-Nov-08 23:46
wielklem11-Nov-08 23:46 
GeneralRe: Creating new buttons (and let them do something) Pin
David Crow12-Nov-08 2:47
David Crow12-Nov-08 2:47 
JokeRe: Creating new buttons (and let them do something) Pin
Mark Salsbery11-Nov-08 6:10
Mark Salsbery11-Nov-08 6:10 
GeneralRe: Creating new buttons (and let them do something) Pin
David Crow11-Nov-08 6:13
David Crow11-Nov-08 6:13 
GeneralRe: Creating new buttons (and let them do something) Pin
Mark Salsbery11-Nov-08 7:00
Mark Salsbery11-Nov-08 7:00 
QuestionCMenu Item Text Pin
h@$@n11-Nov-08 0:41
h@$@n11-Nov-08 0:41 
AnswerRe: CMenu Item Text Pin
CPallini11-Nov-08 0:58
mveCPallini11-Nov-08 0:58 
QuestionProblem with GetAdaptersAddresses in Windows Vista Pin
Hector_M11-Nov-08 0:29
Hector_M11-Nov-08 0:29 
Hi everyone,

I am programming an application which pretends to work under Xp and vista using getAdaptersAddresses function. This function returns code 13 everytime i call it(only in Vista). The following code already works under XP but fails in Vista. I would appreciate any help or tip. Thank you in advance.

{
PIP_ADAPTER_ADDRESSES adapterAddresses = NULL;
PIP_ADAPTER_ADDRESSES adapterAddress = NULL;
DWORD ret = 0;
ULONG len = 0;

len = sizeof (IP_ADAPTER_ADDRESSES);
adapterAddresses = (IP_ADAPTER_ADDRESSES*) malloc(len);
if (adapterAddresses == NULL) {
// Don't care about return value
return INADDR_ANY;
}


// Try to get the size. It is not modified under vista.....

if ((ret=GetAdaptersAddresses(AF_INET, GAA_FLAG_INCLUDE_PREFIX , NULL, adapterAddresses, &len)) == ERROR_BUFFER_OVERFLOW){

// This should happen....

MessageBox(NULL,L"RESERVING",L"LLL",MB_OK);
free(adapterAddresses);

adapterAddresses = (IP_ADAPTER_ADDRESSES*) malloc(len);

if (adapterAddresses == NULL){
return INADDR_ANY;
}
}

// Check return value.

switch(ret){
case NO_ERROR :MessageBox(NULL,L"AdapterAddress OK!!", L"Enter Interfaces", MB_OK);break;
case ERROR_ADDRESS_NOT_ASSOCIATED :MessageBox(NULL,L"AdapterAddress FAILED!!-NO ADDRESS ASSOCIATED", L"Enter Interfaces", MB_OK);break;
case ERROR_BUFFER_OVERFLOW :MessageBox(NULL,L"AdapterAddress FAILED!!-OVERFLOW", L"Enter Interfaces", MB_OK);break;
case ERROR_INVALID_PARAMETER :MessageBox(NULL,L"AdapterAddress FAILED!!- PARAMETERS", L"Enter Interfaces", MB_OK);break;
case ERROR_NOT_ENOUGH_MEMORY :MessageBox(NULL,L"AdapterAddress FAILED!!- NO MEMORY", L"Enter Interfaces", MB_OK);break;
case ERROR_NO_DATA :
MessageBox(NULL,L"AdapterAddress FAILED!!- NO DATA", L"Enter Interfaces", MB_OK);break;

default :
{
LPVOID MsgBuf;
if (FormatMessage(
FORMAT_MESSAGE_ALLOCATE_BUFFER |
FORMAT_MESSAGE_FROM_SYSTEM |
FORMAT_MESSAGE_IGNORE_INSERTS,
NULL,
ret,
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language
(LPTSTR) &MsgBuf,
0,
NULL ))
MessageBox(NULL,(LPCWSTR)MsgBuf,L"ERROR ADAPTER 1",MB_OK);

WCHAR aux[100];
wsprintf(aux,L"Len %d - ret %d",len,ret);
MessageBox(NULL,aux,L"data",MB_OK);

}
break;

}



ret = GetAdaptersAddresses(AF_INET, GAA_FLAG_INCLUDE_PREFIX, NULL, adapterAddresses, &len);


// Check return value
switch(ret){
case NO_ERROR :MessageBox(NULL,L"AdapterAddress OK!!", L"Enter Interfaces", MB_OK);break;
case ERROR_ADDRESS_NOT_ASSOCIATED :MessageBox(NULL,L"AdapterAddress FAILED!!-NO ADDRESS ASSOCIATED", L"Enter Interfaces", MB_OK);break;
case ERROR_BUFFER_OVERFLOW :MessageBox(NULL,L"AdapterAddress FAILED!!-OVERFLOW", L"Enter Interfaces", MB_OK);break;
case ERROR_INVALID_PARAMETER :MessageBox(NULL,L"AdapterAddress FAILED!!- PARAMETERS", L"Enter Interfaces", MB_OK);break;
case ERROR_NOT_ENOUGH_MEMORY :MessageBox(NULL,L"AdapterAddress FAILED!!- NO MEMORY", L"Enter Interfaces", MB_OK);break;
case ERROR_NO_DATA :
MessageBox(NULL,L"AdapterAddress FAILED!!- NO DATA", L"Enter Interfaces", MB_OK);break;
default :
{
LPVOID MsgBuf;

// printf("Call to GetAdaptersAddresses failed.\n");
if (FormatMessage(
FORMAT_MESSAGE_ALLOCATE_BUFFER |
FORMAT_MESSAGE_FROM_SYSTEM |
FORMAT_MESSAGE_IGNORE_INSERTS,
NULL,
ret,
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language
(LPTSTR) &MsgBuf,
0,
NULL ))
MessageBox(NULL,(LPCWSTR)MsgBuf,L"ERROR ADAPTER",MB_OK);
WCHAR aux[100];
wsprintf(aux,L"Len %d - ret %d",len,ret);
MessageBox(NULL,aux,L"data 2 ",MB_OK);
}
break;

}

// Function continues....

}
AnswerRe: Problem with GetAdaptersAddresses in Windows Vista Pin
Hector_M11-Nov-08 2:37
Hector_M11-Nov-08 2:37 
GeneralRe: Problem with GetAdaptersAddresses in Windows Vista Pin
Mark Salsbery11-Nov-08 6:19
Mark Salsbery11-Nov-08 6:19 
GeneralRe: Problem with GetAdaptersAddresses in Windows Vista Pin
Hector_M11-Nov-08 22:00
Hector_M11-Nov-08 22:00 
GeneralRe: Problem with GetAdaptersAddresses in Windows Vista Pin
Mark Salsbery12-Nov-08 6:28
Mark Salsbery12-Nov-08 6:28 
GeneralRe: Problem with GetAdaptersAddresses in Windows Vista Pin
Hector_M12-Nov-08 21:31
Hector_M12-Nov-08 21:31 
GeneralRe: Problem with GetAdaptersAddresses in Windows Vista Pin
David Crow11-Nov-08 7:20
David Crow11-Nov-08 7:20 
Questionproblem in Creating a FILE Pin
m_mun10-Nov-08 23:58
m_mun10-Nov-08 23:58 
AnswerRe: problem in Creating a FILE Pin
sashoalm11-Nov-08 0:26
sashoalm11-Nov-08 0:26 
AnswerRe: problem in Creating a FILE Pin
CPallini11-Nov-08 0:37
mveCPallini11-Nov-08 0:37 
GeneralRe: problem in Creating a FILE Pin
m_mun11-Nov-08 0:50
m_mun11-Nov-08 0:50 
QuestionIs it good practice to use TRY-CATCH in this way? Pin
paresh_joe10-Nov-08 23:33
paresh_joe10-Nov-08 23:33 
AnswerRe: Is it good practice to use TRY-CATCH in this way? Pin
Hector_M11-Nov-08 0:34
Hector_M11-Nov-08 0:34 
AnswerRe: Is it good practice to use TRY-CATCH in this way? Pin
bulg11-Nov-08 7:42
bulg11-Nov-08 7:42 
QuestionProblem occur to access dll dialog box Pin
ShilpiP10-Nov-08 23:20
ShilpiP10-Nov-08 23:20 
AnswerRe: Problem occur to access dll dialog box Pin
SandipG 10-Nov-08 23:26
SandipG 10-Nov-08 23:26 
GeneralRe: Problem occur to access dll dialog box Pin
ShilpiP10-Nov-08 23:49
ShilpiP10-Nov-08 23:49 
AnswerRe: Problem occur to access dll dialog box Pin
CPallini10-Nov-08 23:27
mveCPallini10-Nov-08 23:27 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.