|
For making one application both sever and client.
1. Declare two CSocket objects m_ServerSocket,m_ClientSocket.
2. While starting the application itself start a thread which creates the
m_ServerSocket and keep it listen mode at some port.
3. Put a button by clicking which the m_ClientSocket is created and connected
to the ip and socket value on which server socket is listening.
4. When it reaches the Accept of m_ServerSocket u need to pass a reference of
another CSocket object using which u can communicate back to the client.
Hope this helps u upto some point.
KIRAN PINJARLA
|
|
|
|
|
hi all,
is there any way to access a static varible declared in one file to another file
thank you all
venu
|
|
|
|
|
static, but global, or public member of a class ?
|
|
|
|
|
In general, static variables cannot be external. Static really confines the scope to the current file/block only, which is contradictory to external. So it won't compile if you put them together. In many cases, however, just using extern scope may meet your requirement:
1) in one source file, declare a variable outside all functions.
2) all other declarations should use "extern" keyword.
Best,
Jun
|
|
|
|
|
How can I disable a group of radio buttons? I've tried EnableWindow(FALSE) but it doesn't work because it only works for the head of the group as it is not possible to add control to other radio buttons in the same group. Thanks.
|
|
|
|
|
What you need to do is set the group property to 'group' for all of the other radio button in the group.
Now you can then create the control variables required.
When you have created the control variables go back and remove the group property for the radio buttons that you changed.
You can now use the control variables to enable and disable the radio buttons as required.
|
|
|
|
|
i can't write a program that it modify its code and execute it;
i tried it with assembly too (use _asm , but useless).
That's when i try to modify the virtual table of class with virtual function.
Ex:
class x{
virtual void f1(){cout<<"x::f1"<<endl;};
virtual="" void="" f2(){cout<<"x::f2"<<endl;};
="" others="" here
};
class="" fake{
="" f1(){cout<<"fake::f1"<<endl;};
};
int="" main(){
="" x="" *px="new" x;
="" fake="" *pfake="new" fake;
="" actually,="" i="" use="" pointer="" because="" if="" instance="" of="" object="" then
="" the="" call="" function="" will="" not="" table="" at="" all
="" px-="">f1();//if i call this the result is call x::f1 function
//but if i replace address of x::f1 function in virtual table to
//fake::f1 function then the call px->f1() will call fake::f1 function
//I modify address of x::f1 in vtable like below
DWORD **pfuncAdd = (DWORD **)px;//get address of vtable of class x
DWORD **pfakefunAdd = (DWORD **)px;//get address of vtable of class fake
(*pfuncAdd)[0] = (*pfakefunAdd)[0];//replace x::f1 == fake::f1, but
//i always get access violent while write at the address????
//i think it because i have modified the address inside the code program
//because when i debug i see the address inside code range
//how can i fix it
//if this work done, then when i call px->f1() actually i call fake::f1
}
Please help me, i also try modify my code when running with _asm keyword but
seem i don't know
|
|
|
|
|
blue_rabbit wrote: DWORD **pfuncAdd = (DWORD **)px;//get address of vtable of class x
DWORD **pfakefunAdd = (DWORD **)px;//get address of vtable of class fake
The underlined variable should be pfake .
As for the access violation error, the page which contains the virtual table will be read-only. Try something like this (not tested):
DWORD *pAddress = &((*pfuncAdd)[0]);
DWORD OldProtection;
BOOL OK = VirtualProtect(pAddress, sizeof(LPVOID), PAGE_WRITECOPY, &OldProtection);
if (OK)
{
*pAddress = (*pfakefunAdd)[0];
DWORD Dummy;
VirtualProtect(pAddress, sizeof(LPVOID), OldProtection, &Dummy);
}
Finally, why do you want to do such a thing? Such hackery is, in general, a bad idea.
PS: It would be nice if you went to some effort to make your code readable (for example, indentation and blank lines between sections of code).
Steve
|
|
|
|
|
Oh, thanks you very much! I will try it.
Sorry about "make your code readable", actually i have to type it again because i didn't bring mycode together, if i copy and paste it'll look readable, wont it!
About why? Because i want to see how some game use DirectX and i dont know much about COM, i think if i use COM method i have to create as much interface as game request; and some case DirectX return some interface that i dont know exactly it's created or not. So, it's not my interesting and i chosen this method. With this i actually don't have to create any object but i can see how game use DirectX and may be i can get some good idea.
If you think it's bad idea, could you tell me the popular one!
Thank you!
|
|
|
|
|
Hi
I am reading ( http://msdn2.microsoft.com/en-us/library/ms235627.aspx ) this article.
I created static lib
But i can't achieve this part:
"To use the math routines that were created in the static library, you must reference it. To do this, select References… from the Project menu. From the Property Pages dialog, expand the Common Properties node and select References. Then select the Add New Reference… button.
The Add Reference dialog is displayed. This dialog lists all the libraries that you can reference. The Project tab lists all the projects in the current solution and any libraries they contain. From the Projects tab, select MathFuncsLib. Then select OK. For more information on the Add Reference dialog, see Add Reference Dialog Box."
I click add reference there is nothing there.I can not pass this step.
What do i miss?
How can i reference static lib. to my exe?
I am looking for your answers
Thanks
|
|
|
|
|
How to know from which client we got the connection requiest while we are waiting in the listen mode. I need to chech the ip from which the request has come and to accept the connection request if it is in my list of allowable ip's. I am using CAsyncSocket derived class object as server and client.
Can somebody help me on this.Please?
Thank you.
KIRAN PINJARLA
|
|
|
|
|
Hi,
In Windows Sockets 2 works:
getpeername( );
getnameinfo( );
maybe in CAsyncSocket Class is similar ?
-----------
Mila
|
|
|
|
|
Whenever I use GetModuleFileName I got entry \??\C:\WINNT\system32\csrss.exe like this.What is \??\ means??
|
|
|
|
|
|
No it's english OS and csrss exe is used by windows.
|
|
|
|
|
do you know what unicode is ?
|
|
|
|
|
Hi,
How to add background bitmap to a message box.
Thanks in advance,
Radhika.
|
|
|
|
|
radhika28 wrote: How to add background bitmap to a message box.
Just an idea:
Create your own dialog box and use it like a message box.
Somethings seem HARD to do, until we know how to do them.
_AnShUmAn_
|
|
|
|
|
Hi,
Is it not possible to add background bitmap to message box directly.
Thanks,
Radhika.
|
|
|
|
|
Im not sure but i think you can see an example in www.codeguru.com about messagebox for background
|
|
|
|
|
radhika28 wrote: not possible to add background bitmap to message box directly
You can create a hook for the message box and then display the image as a background on it...
Somethings seem HARD to do, until we know how to do them.
_AnShUmAn_
|
|
|
|
|
Thanks both for ur reply's,
But,I have searched for it in codeproject and also codeguru but i am not able to get the suitable information.
And also my doubt is how can we create hook for the message box.
Radhika.
|
|
|
|
|
radhika28 wrote: how can we create hook for the message box
By using:
SetWindowsHookEx , CallNextNextHookEx and UnInstallHook
Somethings seem HARD to do, until we know how to do them.
_AnShUmAn_
|
|
|
|
|
|
Hello radhika,
I hope this will helpfull to u.
I know it is C# project. But as it is developed in MFC.
So, it may be helpfull to u.
regards,
Divyang Mithaiwala
System Engineer & Software Developer
|
|
|
|