UuidFromString not creating GUID correctly - Help!
-
In this function i am trying to disable the dchp in the adapter register key. Also i am notify the NICs driver that the settings have changed. bool CTcpIpPropertiesChangerApp::DisableDchp() { char szValue[MAX_GUID_STRING_LEN]; CString str,str2; DWORD pdw=99; CRegKey key,key2; for(int flag=1;flag<=100;flag++) { str.Format("SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\NetworkCards\\%d",flag); if(key.Open(HKEY_LOCAL_MACHINE,str,KEY_READ|KEY_WRITE)==ERROR_SUCCESS) { key.QueryValue(szValue,"ServiceName",&pdw); key.Close(); str.Format("SYSTEM\\CurrentControlSet\\Services\\TcpIp\\Parameters\\Interfaces\\%s",szValue); key.Open(HKEY_LOCAL_MACHINE,str,KEY_WRITE); key.Open(HKEY_LOCAL_MACHINE,str,KEY_WRITE); DWORD keyy=0; ::RegSetValueEx(key.m_hKey,"EnableDHCP",0,REG_DWORD,(PBYTE) &keyy,sizeof(PDWORD)); key.Close(); HDEVINFO hDevInfo = SetupDiGetClassDev (NULL,NULL,NULL,DIGCF_ALLCLASSES); if( INVALID_HANDLE_VALUE == hDevInfo ) { AfxMessageBox("Error :SetupDiGetClassDevs()"); return FALSE; } //An SP_PROPCHANGE_PARAMS structure corresponds to a DIF_PROPERTYCHANGE installation request. SP_PROPCHANGE_PARAMS spPropChangeParams; spPropChangeParams.ClassInstallHeader.cbSize = sizeof(SP_CLASSINSTALL_HEADER); spPropChangeParams.ClassInstallHeader.InstallFunction = DIF_PROPERTYCHANGE; spPropChangeParams.Scope = DICS_FLAG_GLOBAL; spPropChangeParams.StateChange = DICS_DISABLE; spPropChangeParams.HwProfile = 0; //An SP_DEVINFO_DATA structure defines a device instance that is a member of a device information set. SP_DEVINFO_DATA spDevInfoData; spDevInfoData.cbSize = sizeof(SP_DEVINFO_DATA); for (int k=0;SetupDiEnumDeviceInfo(hDevInfo,k,&spDevInfoData);k++) { unsigned char GuidString[MAX_GUID_STRING_LEN]; GuidString[MAX_GUID_STRING_LEN - 2] = _T('\0'); for(int l=0;l
-
In this function i am trying to disable the dchp in the adapter register key. Also i am notify the NICs driver that the settings have changed. bool CTcpIpPropertiesChangerApp::DisableDchp() { char szValue[MAX_GUID_STRING_LEN]; CString str,str2; DWORD pdw=99; CRegKey key,key2; for(int flag=1;flag<=100;flag++) { str.Format("SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\NetworkCards\\%d",flag); if(key.Open(HKEY_LOCAL_MACHINE,str,KEY_READ|KEY_WRITE)==ERROR_SUCCESS) { key.QueryValue(szValue,"ServiceName",&pdw); key.Close(); str.Format("SYSTEM\\CurrentControlSet\\Services\\TcpIp\\Parameters\\Interfaces\\%s",szValue); key.Open(HKEY_LOCAL_MACHINE,str,KEY_WRITE); key.Open(HKEY_LOCAL_MACHINE,str,KEY_WRITE); DWORD keyy=0; ::RegSetValueEx(key.m_hKey,"EnableDHCP",0,REG_DWORD,(PBYTE) &keyy,sizeof(PDWORD)); key.Close(); HDEVINFO hDevInfo = SetupDiGetClassDev (NULL,NULL,NULL,DIGCF_ALLCLASSES); if( INVALID_HANDLE_VALUE == hDevInfo ) { AfxMessageBox("Error :SetupDiGetClassDevs()"); return FALSE; } //An SP_PROPCHANGE_PARAMS structure corresponds to a DIF_PROPERTYCHANGE installation request. SP_PROPCHANGE_PARAMS spPropChangeParams; spPropChangeParams.ClassInstallHeader.cbSize = sizeof(SP_CLASSINSTALL_HEADER); spPropChangeParams.ClassInstallHeader.InstallFunction = DIF_PROPERTYCHANGE; spPropChangeParams.Scope = DICS_FLAG_GLOBAL; spPropChangeParams.StateChange = DICS_DISABLE; spPropChangeParams.HwProfile = 0; //An SP_DEVINFO_DATA structure defines a device instance that is a member of a device information set. SP_DEVINFO_DATA spDevInfoData; spDevInfoData.cbSize = sizeof(SP_DEVINFO_DATA); for (int k=0;SetupDiEnumDeviceInfo(hDevInfo,k,&spDevInfoData);k++) { unsigned char GuidString[MAX_GUID_STRING_LEN]; GuidString[MAX_GUID_STRING_LEN - 2] = _T('\0'); for(int l=0;l
use GUID *ret; ret = new GUID; instead of GUID ret; after that delete ret -Sachin
-
use GUID *ret; ret = new GUID; instead of GUID ret; after that delete ret -Sachin
hi sachin, Thanks for replying. But that didnt work. Now the 'ret' just gets created with the default value 'CDCDCDCD-CDCD-CDCD-CDCDCDCDCDCD}' and the funtion UuidFromString() produces no effect on it. any other idea??
Priya Sundar
-
In this function i am trying to disable the dchp in the adapter register key. Also i am notify the NICs driver that the settings have changed. bool CTcpIpPropertiesChangerApp::DisableDchp() { char szValue[MAX_GUID_STRING_LEN]; CString str,str2; DWORD pdw=99; CRegKey key,key2; for(int flag=1;flag<=100;flag++) { str.Format("SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\NetworkCards\\%d",flag); if(key.Open(HKEY_LOCAL_MACHINE,str,KEY_READ|KEY_WRITE)==ERROR_SUCCESS) { key.QueryValue(szValue,"ServiceName",&pdw); key.Close(); str.Format("SYSTEM\\CurrentControlSet\\Services\\TcpIp\\Parameters\\Interfaces\\%s",szValue); key.Open(HKEY_LOCAL_MACHINE,str,KEY_WRITE); key.Open(HKEY_LOCAL_MACHINE,str,KEY_WRITE); DWORD keyy=0; ::RegSetValueEx(key.m_hKey,"EnableDHCP",0,REG_DWORD,(PBYTE) &keyy,sizeof(PDWORD)); key.Close(); HDEVINFO hDevInfo = SetupDiGetClassDev (NULL,NULL,NULL,DIGCF_ALLCLASSES); if( INVALID_HANDLE_VALUE == hDevInfo ) { AfxMessageBox("Error :SetupDiGetClassDevs()"); return FALSE; } //An SP_PROPCHANGE_PARAMS structure corresponds to a DIF_PROPERTYCHANGE installation request. SP_PROPCHANGE_PARAMS spPropChangeParams; spPropChangeParams.ClassInstallHeader.cbSize = sizeof(SP_CLASSINSTALL_HEADER); spPropChangeParams.ClassInstallHeader.InstallFunction = DIF_PROPERTYCHANGE; spPropChangeParams.Scope = DICS_FLAG_GLOBAL; spPropChangeParams.StateChange = DICS_DISABLE; spPropChangeParams.HwProfile = 0; //An SP_DEVINFO_DATA structure defines a device instance that is a member of a device information set. SP_DEVINFO_DATA spDevInfoData; spDevInfoData.cbSize = sizeof(SP_DEVINFO_DATA); for (int k=0;SetupDiEnumDeviceInfo(hDevInfo,k,&spDevInfoData);k++) { unsigned char GuidString[MAX_GUID_STRING_LEN]; GuidString[MAX_GUID_STRING_LEN - 2] = _T('\0'); for(int l=0;l
Priya_Sundar wrote:
GUID ret; UuidFromString(&GuidString[1], &ret);
GUID ret = { 0 }; UuidFromString(GuidString, &ret);
Nibu thomas MVP For VC++ Code must be written to be read, not by the compiler, but by another human being. Programming Blog: http:\\nibuthomas.wordpress.com
-
Priya_Sundar wrote:
GUID ret; UuidFromString(&GuidString[1], &ret);
GUID ret = { 0 }; UuidFromString(GuidString, &ret);
Nibu thomas MVP For VC++ Code must be written to be read, not by the compiler, but by another human being. Programming Blog: http:\\nibuthomas.wordpress.com
Hi, That didnt work. now 'ret' is created with default val "{00000000-0000-0000-0000-000000000000}" and the function UuidFromString() causes no effect.. Thankyou for your sugesstion! Any more ideas??
Priya Sundar
-
Hi, That didnt work. now 'ret' is created with default val "{00000000-0000-0000-0000-000000000000}" and the function UuidFromString() causes no effect.. Thankyou for your sugesstion! Any more ideas??
Priya Sundar
Priya_Sundar wrote:
UuidFromString
What does the return value from UuidFromString say. Refer MSDN for more information. Check given GUID string.
Nibu thomas MVP For VC++ Code must be written to be read, not by the compiler, but by another human being. Programming Blog: http:\\nibuthomas.wordpress.com
-
Priya_Sundar wrote:
UuidFromString
What does the return value from UuidFromString say. Refer MSDN for more information. Check given GUID string.
Nibu thomas MVP For VC++ Code must be written to be read, not by the compiler, but by another human being. Programming Blog: http:\\nibuthomas.wordpress.com
MSDN: This is the syntax of the function UuidFromString() for the version vc++6.0 RPC_STATUS RPC_ENTRY UuidFromString ( unsigned char *StringUuid, UUID *Uuid ); New 2005 version: RPC_STATUS RPC_ENTRY UuidFromString ( unsigned char __RPC_FAR* StringUuid, UUID __RPC_FAR* Uuid ); I am using vc++6.0 with PSDK and i guess __RPC_FAR wont be the cause of the problem. Further, i have modified it as, unsigned char *GuidString; GuidString = (unsigned char *)szValue; //szValue being declared as "char szValue[MAX_GUID_STRING_LEN];" and having a val "{A89377EA-D4ED-4A03-A37F-4A9DE785E1A9}" GUID ret = { 0 }; UuidFromString(GuidString,&ret); now UuidFromString returns RPC_S_INVALID_STRING_UUID stating that the string UUID is invalid.
Priya Sundar
-
MSDN: This is the syntax of the function UuidFromString() for the version vc++6.0 RPC_STATUS RPC_ENTRY UuidFromString ( unsigned char *StringUuid, UUID *Uuid ); New 2005 version: RPC_STATUS RPC_ENTRY UuidFromString ( unsigned char __RPC_FAR* StringUuid, UUID __RPC_FAR* Uuid ); I am using vc++6.0 with PSDK and i guess __RPC_FAR wont be the cause of the problem. Further, i have modified it as, unsigned char *GuidString; GuidString = (unsigned char *)szValue; //szValue being declared as "char szValue[MAX_GUID_STRING_LEN];" and having a val "{A89377EA-D4ED-4A03-A37F-4A9DE785E1A9}" GUID ret = { 0 }; UuidFromString(GuidString,&ret); now UuidFromString returns RPC_S_INVALID_STRING_UUID stating that the string UUID is invalid.
Priya Sundar
Priya_Sundar wrote:
and having a val "{A89377EA-D4ED-4A03-A37F-4A9DE785E1A9}"
Try removing "{...}" from the beginning and from the end of the string.
Nibu thomas MVP For VC++ Code must be written to be read, not by the compiler, but by another human being. Programming Blog: http:\\nibuthomas.wordpress.com
-
Priya_Sundar wrote:
and having a val "{A89377EA-D4ED-4A03-A37F-4A9DE785E1A9}"
Try removing "{...}" from the beginning and from the end of the string.
Nibu thomas MVP For VC++ Code must be written to be read, not by the compiler, but by another human being. Programming Blog: http:\\nibuthomas.wordpress.com
Hai Nibu, wowwww!!!!! Thanks a lotttttttttttttttttttttt!! It solved it. Have a nice day. :):rose:
Priya Sundar