|
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<max_guid_string_len;l++)
guidstring[l]="szValue[l];
" guid="" ret;
="" uuidfromstring(&guidstring[1],="" &ret);
="" if(spdevinfodata.classguid="=" ret="" )
="" {
="" setupdisetclassinstallparams="" sets="" or="" clears="" class="" install="" parameters="" for="" a="" device="" information="" set="" particular="" element.=""
="" if="" (="" setupdisetclassinstallparams(hdevinfo,="" &spdevinfodata,="" (sp_classinstall_header="" *)&sppropchangeparams,="" sizeof(sppropchangeparams))="=" false)="" setupdidestroydeviceinfolist="" (hdevinfo);
="" return="" false;="" }
="" setupdicallclassinstaller="" calls="" the="" appropriate="" installer,="" and="" any="" registered="" co-installers,="" with="" specified="" installation="" request="" (dif="" code).
="" (setupdicallclassinstaller(dif_propertychange,="" hdevinfo,="" &spdevinfodata)="=FALSE)" }
="" }="" }
}<="" code="">
For this i am trying to create a GUID inside the second for loop where in i get "{CCCCCCCC-CCCC-CCCC-CCCC-CCCCCCCCCCCC}" as 'ret' value instead of {A89377EA-D4ED-4A03-A303-A37F-4A9DE785E1A9} which is the '&GuidString[1]' value.
I think i need to typecast correctly.
Kindly help!
Priya Sundar
|
|
|
|
|
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
|
|
|
|
|
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
|
|
|
|
|
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
|
|
|
|
|
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.
Priya Sundar
|
|
|
|
|
Hi,
I have heard of core dump, but i have no idea what is it ? How to use it in Visual Studio for debugging ?
Is it a file ??
Please help me in understnading this....
|
|
|
|
|
Hi,
I want to replace the message box icon with my own icon. But i don't know how to get the Handle to message box icon.
Any suggestions are welcome.
|
|
|
|
|
U will have to design a dialog box similar to message box and calll domodal for this newly designed dialog.
-sachin
|
|
|
|
|
Lakshmi_p wrote: I want to replace the message box icon with my own icon. But i don't know how to get the Handle to message box icon.
Use MessageBoxIndirect and MSGBOXPARAMS . Look here[^] for a demo.
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
|
|
|
|
|
Ho. Simple solution. I removed my post.
|
|
|
|
|
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,
Thanks for ur reply.
Can we get the handle of messagebox default icon based on its its styles.
|
|
|
|
|
Hello again.
Hope somebody can help me. When i create setup file in VC++ 2003 MFC I included configuration (*.ini) file which is needed in running the software. But if the user install it to a different location, I can't track or locate it so the *.ini file appears not to be found.
How can I track it in my code so wherever it resides I can still find it?
Or other trick perhaps.
That's all. Thank you.
|
|
|
|
|
|
Thanks nave.
I think that makes sense.
It's a big help.
Till next time.
God Bless.
|
|
|
|
|
See if GetModuleFileName(NULL, ...) helps, which is different than GetCurrentDirectory() .
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Hi all,
I am using ipl98 library version 2.20 and I was compile it successful. However, I can only use the static library is created by VC++.net (It can run ok with the example in ipl98 library project.) The dynamic library cannot use it to run the example.
About Borland C++, I also compile successfully but the dynamic library cannot do with the example. After that I compile it to create the static library, this is not successful, the error: library too large, please restart with library page size 32.
My purpose is using ipl98 library version 2.20 in the Borland C++. However, I spent a lot of time but until now I also cannot use it in the Borland C++. If you have any advices, any ideas, or any instructions please show me!
Can we use the static library created by VC++.net to transition dynamic library? Or Can we use the static library in Borland C++? Or you have another ways to solve it.
I hope I will get your feedback as soon as possible.
Best regards!
nothing
|
|
|
|
|
Hello:
Looking for local (around Western Philadelphia, PA suburbs -- preferably Exton/Malvern area) person with experience coding C++ Windows Mobile apps.
SQL Server 2000/2005 experience helps.
Please send me a note if you are local and interested.
Please (please) no recruiters and check the map to see if you are local first. India is not local
Thanks
~Bill
Admin -- please move this if it belongs in a different forum area.
-- modified at 8:04 Monday 15th October, 2007
|
|
|
|
|
Hi all. I was trying to make something that will try to reconnect on a severed connection from the server. Now i know WSAGetLastError only works if a message is trying to be sent from client to server, and a error code is returned in case the message doesnt go through. So i did the following:
Started a server.
Connected client
Turned server off.
And i got error code 183 in return.
So i figured, if i can match it then i should be able to reconnect.
<br />
if(WSAGetLastError()==183){<br />
...
}<br />
But to no avail it didnt work. So what should i do in a situation like this? Any suggestions? Thanx in advance!
|
|
|
|
|
Where are you checking for this value at?
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
I setup a function thread to loop over and over to send request from the server as long as Connected=true; once thats set to true the function starts to send request. I made a simple ofstream function to test whether or not it works if the connection was severed.
<br />
ofstream out;<br />
out.open("error.txt",ios::app);<br />
out << WSAGetLastError << endl;<br />
out.close();<br />
Soon as i turned the server off it made the file with error code 183 in it. (Several times too because of the loop)
I need to know how to use this in a if statement.
|
|
|
|