|
Hi,
I am doing a small chatter prog, which also can send some files and so on. How do I enumerate all machines in a lan, which are currently running the chatter prog (I am thinking of a similiar enumeration like it is done in games).
tia.
-widi
|
|
|
|
|
My idea:
Anonymous wrote:
How do I enumerate all machines in a lan
You can use UDP broadcast datagram. And then
Anonymous wrote:
which are currently running the chatter prog
all your clients have to listen on selected port to that UDP datagram. They will respond somehow (like, hey, I am here ... etc.) with datagram sent to your server.
At the server side you will receive datagrams with clients' IP adresses, it means, you will have a list of all clients on your LAN.
|
|
|
|
|
tanks, i'll check it out.
-widi
|
|
|
|
|
hi friend
LPSERVER_INFO_100 pBuf=NULL;
LPSERVER_INFO_100 pTmpBuf;
DWORD dwEntriesRead = 0;
DWORD dwTotalEntries = 0;
NET_API_STATUS nStatus;
DWORD i;
nStatus = NetServerEnum(NULL, 100, (LPBYTE *) &pBuf, MAX_PREFERRED_LENGTH, &dwEntriesRead,
&dwTotalEntries, SV_TYPE_ALL, NULL, 0);
if ((nStatus == NERR_Success) || (nStatus == ERROR_MORE_DATA))
{
pTmpBuf=pBuf;
for (i = 0; i < dwEntriesRead; i++)
{
USES_CONVERSION;
LPTSTR str = OLE2T((const unsigned short *)pTmpBuf->sv100_name);
if(m_ctrlComboNetSendTo .AddString(str)==CB_ERR || m_ctrlComboProxyAs .AddString(str)==CB_ERR)
break;
pTmpBuf++;
}
}
if (pBuf != NULL)
NetApiBufferFree(pBuf);
here i use m_ctrlComboProxyAs as a control variable of type COMBO
and str is a bufferr
in the loop u get the machine name one at a time
try it
Renjith The True CP ian
|
|
|
|
|
You are right, however SV_TYPE_ALL does not necessary mean:
Anonymous wrote:
enumerate all machines in a lan, which are currently running the chatter prog
|
|
|
|
|
thanks, that's what i needed.
-widi
|
|
|
|
|
In my application I need to draw a gradient in the window non-client area. I pass a window device context to the GradientFill(…) Win32 API function. However, under WinMe gradient is drawn incorrectly, it somehow clipped. Everything is OK under Win2000 and WinXP.
I developed a dummy dialog-based example program where this bug is reproducible. The following are 2 functions of interest:
void CTestDlg::OnGradientFill()
{
CRect rect;
GetWindowRect(&rect);
// offset from screen to window coordinates
rect.OffsetRect(-rect.left, -rect.top);
// get window device context
HDC hDC = ::GetWindowDC(m_hWnd);
// draw gradient
DrawGradient(hDC, rect);
// clean up
::ReleaseDC(m_hWnd, hDC);
}
void CTestDlg::DrawGradient(HDC hDC, const CRect& rect)
{
// This code is borrowed from MSDN
// article "Drawing a Shaded Rectangle"
TRIVERTEX vert[2] ;
GRADIENT_RECT gRect;
vert [0] .x = rect.left;
vert [0] .y = rect.top;
vert [0] .Red = 0x0000;
vert [0] .Green = 0x0000;
vert [0] .Blue = 0x0000;
vert [0] .Alpha = 0x0000;
vert [1] .x = rect.right;
vert [1] .y = rect.bottom;
vert [1] .Red = 0x0000;
vert [1] .Green = 0x0000;
vert [1] .Blue = 0xff00;
vert [1] .Alpha = 0x0000;
gRect.UpperLeft = 0;
gRect.LowerRight = 1;
GradientFill(hDC,vert,2,&gRect,1,GRADIENT_FILL_RECT_H);
}
For comparison I have included to the example program a call to FillRect(…) with the same device context. Everything draws correctly both under WinMe and other systems!
Could graphics experts somehow comment on this issue? Is it a bug in the Microsoft’s implementation of the GradientFill(…) function under WinMe? I can send a demo project to those who will be interested.
My environment:
WinMe/WinXP, Visual C++ 6.0, SP5, Platform SDK August 2001
Thanks, any comments will be greatly appreciated!
Victor
|
|
|
|
|
Hi,
I have developed an application that runs on the
client machine throughout the System lifetime.
Now its like, i want to sometimes update this application
with newer versions.
Please, i want some suggestions on how to perform this
kind of activity.
Do I need to run, one more program or what?
Please help
Sameer
|
|
|
|
|
A typically used technique is that program A starts B passing to B it's process handle and then exits. B waits on the handle and keeps waiting till A exits. Then B copies the new file over the existing file and restarts A and then exits.
Nish
Regards,
Nish
Native CPian.
Born and brought up on CP.
With the CP blood in him.
|
|
|
|
|
Nish - Native CPian wrote:
B waits on the handle and keeps waiting till A exits
Thanx for the help, but how can B wait till A exits,
I mean how to do that??
Sameer
|
|
|
|
|
Sameer Maggon wrote:
but how can B wait till A exits,
B should call WaitForSingleObject on A's process handle which A should pass to B
Nish
Regards,
Nish
Native CPian.
Born and brought up on CP.
With the CP blood in him.
|
|
|
|
|
I'm using some COM components in my VC++ project, I was expecting one of those methods return "_RecordsetPtr", but it in fact returns "IDispatchPtr", I'm new on COM stuff, how to convert it into a _RecordsetPtr? Thanks a lot.
|
|
|
|
|
I had a look on Code Project but could not find what I was looking for.
Can anybody direct me to an article that covers adding a button to the title bar of an application. I want to add one next to the 'minimize' button.
Thanks - Joel
|
|
|
|
|
I don't know of one off the top of my head, but this article might give you a start.
--------
A closed mouth gathers no foot. --Shog9 --
|
|
|
|
|
this is not from code project.
But i guess it does'nt matter?
http://www.codeguru.com/dialog/custom_dialog_caption.shtml
|
|
|
|
|
would you please tell me about som win32 API which provide
accessing(Read/Write)
to FAT32 logical partion on my hard disk.
As mater of fact,I want to read or write some data from/to FAT32
partitions in
my VC++ program.
I perform it on FAT16 system with using VWIN32 services and
_DIOC_REGISTERS
but it failed on FAT32.
there is some assembly snippet code in MSDN help library,but I
couldn't compile
and run it in VC++ with __asm keyword in my code as see below
__asm{
mov si, 6001h ;write normal file data. SI=0 for read
;see "In Write Mode" below for more write
values
mov cx, -1 ;cx must be -1
mov dx, seg Buffer
mov ds, dx
mov bx, offset Buffer ;See below
mov dl, DriveNum ;See below
mov ax, 7305h ;Ext_ABSDiskReadWrite
int 21h
jc error_handler ;carry set means error
}
I got some compile error on line 3(mov dx,seg Buffer) and on line
5(mov bx,offset Buffer).
I tried it with _DIOC_REGISTERS and DeviceIoControl with VWIN32 file
handler
but i got error number 87 that means "incorrect parameters".
please help me with your advices or introduce me some useful sites to
solving this problem.
please sne it to
karimi@rcii-ir.org
|
|
|
|
|
if you declare the amount of info that you want to store in a char like...
char ID[10];
that would mean that id has 10 slots + \0; right?
now, if i would want to print out all the info from char ID... wouldnt i just..
cout << ID;?
and if you wrote:
cout << ID[2];
you would get the third memory slot, right?
why cant i set M_ID = ID? M_ID is [10] and so is ID.
bool ID::SetID(char ID[10])
{
M_ID = ID
return true;
}
i get an error when i put this in, and the only way i get rid of it is if i make:
ID[]; and within the [] i would have to have a number. but i want all of ID = M_ID.., what do i do? what do i put in the []?
also... if there is a good tutorial that teaches how to compare data, and all the little detail of do what im trying to do, please make note of it.
Thanks!
~SilverShalkin
ps... I started this message like 1-2 hours ago, and kept jumping back to my code and trying new things... so if the message is unclear about my mainpoint "question" just tell me, and i will refrase it in a more understandable way
|
|
|
|
|
A C-style string is stored in a char array, however a char array is not magically a string. You must ensure that the array is properly null-terminated. The way you do that is to always use the string functions when manipulating strings.
SilverShalkin wrote:
char ID[10];
that would mean that id has 10 slots + \0; right?
No, that declares a 10-character array. Again, it's not magically a string. It just contains 10 characters.
SilverShalkin wrote:
now, if i would want to print out all the info from char ID... wouldnt i just..
cout << ID;?
As long as ID is null-terminted, that's correct.
SilverShalkin wrote:
bool ID::SetID(char ID[10])
{
M_ID = ID;
}
That is an error because you can't assign strings (or any arrays) with =. You copy a string with strcpy() .
--Mike--
Just released - RightClick-Encrypt - Adds fast & easy file encryption to Explorer
Like the Google toolbar? Then check out UltraBar, with more features & customizable search engines!
My really out-of-date homepage
Sonork - 100.10414 AcidHelm
|
|
|
|
|
thanks!
i was using strcpy() but then switched over because things werent working... ill try it again.
Any tutorials?
Thanks again!
~SilverShalkin
|
|
|
|
|
SilverShalkin wrote:
Any tutorials?
Any C beginners book. And you can look up in MSDN if you have any problems.
Best regards,
Alexandru Savescu
|
|
|
|
|
hi, all.
since the COM program must include the afx.h(once include afx.h, cannot include windows.h), and the project setting must "use mfc in a share library(or static library)", does that mean the COM must require MFC support?
|
|
|
|
|
Not at all, COM and MFC have no dependencies on each other, although you certainly can use them together. Are you still having trouble compiling with a reference to IActiveDesktop* ?
--Mike--
Just released - RightClick-Encrypt - Adds fast & easy file encryption to Explorer
Like the Google toolbar? Then check out UltraBar, with more features & customizable search engines!
My really out-of-date homepage
Sonork - 100.10414 AcidHelm
|
|
|
|
|
Thanks Mike. my problem has been solved since i include the afx.h, afxdisp.h, and wininet.h, i just got a little bit confused about that, so i answer that question.
well, as you said, COM and MFC have no dependencies on each other. but on the other hand, i still cannot complied that program with the project setting "Not using MFC". could u explain that, or give a simple example.;)
|
|
|
|
|
IIRC your original code didn't use MFC, right? #include'ing afx*.h is not the right thing to do, since those are MFC headers. #include wininet.h before shlobj.h and you should be set.
(If your program is using MFC, then just change that combo box to the proper MFC type [shared DLL or static LIB].)
--Mike--
Just released - RightClick-Encrypt - Adds fast & easy file encryption to Explorer
Like the Google toolbar? Then check out UltraBar, with more features & customizable search engines!
My really out-of-date homepage
Sonork - 100.10414 AcidHelm
|
|
|
|
|
Oh, i see. Thank you very much.
|
|
|
|