|
how to know info about sockets currently run in a PC?
the sockets are created by other apps.
info includes ports, addresses for both side of sockets.
is it possible?
thx
includeh10
|
|
|
|
|
one link http://www.sysinternals.com/ntw2k/source/tcpview.shtml
Papa
Murex Co.
while (TRUE)
Papa.WillLove ( Bebe ) ;
|
|
|
|
|
another one http://www.sysinternals.com/ntw2k/freeware/tdimon.shtml
Papa
Murex Co.
while (TRUE)
Papa.WillLove ( Bebe ) ;
|
|
|
|
|
thank u!
before i try, i want to know if it is only avaliable on NT and win2k?
a flower ...
includeh10
|
|
|
|
|
there's a version for win 95/98/Me also, check it out at www.sysinternals.com
Papa
Murex Co.
while (TRUE)
Papa.WillLove ( Bebe ) ;
|
|
|
|
|
i downloaded 20 (or all) zips from the company. they look very wanderful!
i will go through to find key code.
i think u use them before, u should be an expert about the stories.
thx again
2 flowers ...
includeh10
|
|
|
|
|
another tool: in MS-DOS command window, type "netstat -a".
|
|
|
|
|
OK I have my app which I am trying to test on other machines
I have built it as a Multi threaded DLL so I am using the MSVCRT.dll
as well as the MSVCP60.dll due to C++ and STL
On my machine (a win2K box) all is well.
On the two NT server 4 sp6 machines where I ahve tried to run it all is NOT well.
I put the exe plus my lib's .dll and the msvcrt.dll and msvcp60.dll all in the same directory.
I try and run the app (it is a console app) and I get this:
"The procedure entry point __lc_collate_cp could not be located in the dynamic link library MSVCRT.dll"
Hmm...well I drag a copy of depends.exe over and open the app in it and it reports no errors ( i.e. problems with linked functions that don't exist), and in fact reports that the version of MSVCRT.dll I am using is the one in the app's directory (naturally), NOT the one in winnt\system32\.
The one in the c:\winnt\system32\ dir has a version of 4.20.6201 and the one I am using (or need to use) is 6.10.8924.0
I had always understood that you should avoid replacing the stuff in system32 to prevent breakage in other apps.
Should I in fact change the installer to just overwrite it (if it is older than mine) ?
This app will be installed on server machines so I am a but leery of doing this.
Any suggestions will be greatly appreciated, and I happily send you a virtual beer !
|
|
|
|
|
Well, this masks the error rather than solve it, but have you considered statically linking the pogram? When I have to release an applicaton I always choose this option to save me the hassle and latenight calls from clients
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Yeah thats what I am getting readyto do now but I am REALLY pissed off that I have to resort to this. Stupid fsckin' MS, pardon my french....
|
|
|
|
|
Jim Crafton wrote:
Hmm...well I drag a copy of depends.exe over and open the app in it and it reports no errors ( i.e. problems with linked functions that don't exist), and in fact reports that the version of MSVCRT.dll I am using is the one in the app's directory (naturally), NOT the one in winnt\system32\.
The one in the c:\winnt\system32\ dir has a version of 4.20.6201 and the one I am using (or need to use) is 6.10.8924.0
I had always understood that you should avoid replacing the stuff in system32 to prevent breakage in other apps.
Should I in fact change the installer to just overwrite it (if it is older than mine) ?
This app will be installed on server machines so I am a but leery of doing this.
Yes, you should change the installer to overwrite it.
Depends.exe seems to give you the wrong hint here
The problem is, that on NT4 (and maybe also Win2k, but not XP) MSVCRT.dll is a so-called "well-known DLL" (the list of well-known DLLs is stored in the registry at HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\KnownDLLs).
These DLLs are never loaded side-by-side, because they are a vital part of the OS. For well-known DLLS always the copy in %SYSTEMROOT%\System32 is taken.
While this makes much sense for the "really vital" OS DLLs e.g. kernel32.dll and advapi32.dll, which are heavily dependend on each other and replacing one of them side-by-side with another version could break the whole system, I never understood why msvcrt.dll is also on this list. But on NT4 it is!
So the official and recommended way is to replace it. However, msvcrt.dll is the very best tested thing from MS and, (regarding DLL-Hell) in no way comparable with MFC or Common Controls: Every of their own application and every OS component depends on it . So it is rather safe to replace it with a newer version (and do the damned reboot afterwards). In fact, I have never heard of any problem with replacing it.
--
Daniel Lohmann
http://www.losoft.de
|
|
|
|
|
Thanks for hte info ! I will change the installer to do this then.
I had never heard about the "well known DLL" issue, and while I kind of understand it, that REALLY sucks. I wonder what would happen if you were to just remove the entry?
Curiously, I just walked over to the one of the machines and opened regedit and I saw a number of DLLs under the HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\KnownDLLs key but NOT msvcrt.dll - is this one hardcoded somewhere else I wonder ?
|
|
|
|
|
Jim Crafton wrote:
Curiously, I just walked over to the one of the machines and opened regedit and I saw a number of DLLs under the HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\KnownDLLs key but NOT msvcrt.dll - is this one hardcoded somewhere else I wonder ?
Oh sorry - I was not able to check this (no NT4 box available here ).
AFAIR (it's some time ago I struggled about this topic) the "know-dll" property is a transitive property. This means, that every DLL that is implicitly loaded from a known-dll is also treated as known-dll (The whole mechanism is for stability purposes, so this makes sense). I simply assume that some of the DLLs imports msvcrt.dll.
Hm...
I just checked it on my XP box. Using the "WinObj" tool from http://www.sysinternals.com[^] you can view all dlls that are actually treated as a known dll (also the imported ones). And I had to find out that even on XP msvcrt.dll is a member of this list
Obviously you just not ran into problems on Win2k and above, because it is shipped with a newer version of msvcrt.dll. Your side-by-side copy has never been loaded on any version of NT, it is just wasting disk space...
--
Daniel Lohmann
http://www.losoft.de
(Hey, this page is worth looking! You can find some free and handy NT tools there )
|
|
|
|
|
Hi all,
I am learning window programming.
I want to draw text when my mouse moves on client rectangle.
I have two alternatives to choose from
1. TextOut
2. DrawText
Which one should I use and why?
I try with the simple test code using TextOut to draw text at point(10,30) on client rect
But I don't get it work.
the code is as follow:
LRESULT CALLBACK WndProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
HDC hdc ;
PAINTSTRUCT ps ;
RECT rect ;
TCHAR szBuff[10] = "Hello";
switch (message)
{
.....
case WM_MOUSEMOVE:
hdc = BeginPaint (hwnd, &ps) ;
TextOut (hdc, 10, 30, szBuff, lstrlen(szBuff));
EndPaint (hwnd, &ps) ;
return 0 ;
..........
}
}
int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance,
PSTR szCmdLine, int iCmdShow)
{
static TCHAR szAppName[] = TEXT ("HelloWin") ;
HWND hwnd ;
MSG msg ;
WNDCLASS wndclass ;
wndclass.style = CS_HREDRAW | CS_VREDRAW | CS_DBLCLKS ;
wndclass.lpfnWndProc = WndProc ;
wndclass.cbClsExtra = 0 ;
wndclass.cbWndExtra = 0 ;
wndclass.hInstance = hInstance ;
wndclass.hIcon = LoadIcon (NULL, IDI_APPLICATION) ;
wndclass.hCursor = LoadCursor (NULL, IDC_ARROW) ;
wndclass.hbrBackground = (HBRUSH) GetStockObject (WHITE_BRUSH) ;
wndclass.lpszMenuName = NULL ;
wndclass.lpszClassName = szAppName ;
if (!RegisterClass (&wndclass))
{
MessageBox (NULL, TEXT ("This program requires Windows NT!"),
szAppName, MB_ICONERROR) ;
return 0 ;
}
hwnd = CreateWindow (szAppName, // window class name
TEXT ("The Hello Program"), // window caption
WS_OVERLAPPEDWINDOW, // window style
CW_USEDEFAULT, // initial x position
CW_USEDEFAULT, // initial y position
CW_USEDEFAULT, // initial x size
CW_USEDEFAULT, // initial y size
NULL, // parent window handle
NULL, // window menu handle
hInstance, // program instance handle
NULL) ; // creation parameters
ShowWindow (hwnd, iCmdShow) ;
UpdateWindow (hwnd) ;
while (GetMessage (&msg, NULL, 0, 0))
{
TranslateMessage (&msg) ;
DispatchMessage (&msg) ;
}
return msg.wParam ;
}
Once I get the above code to work then I would like that text "Hello" is followed when I move my mouse on the client area.
I would appreciate if you could give my a sample code for that or any suggesion.
Thanks in advance
regards
/rsasalm
|
|
|
|
|
Hi,
OK your first problem is here
case WM_MOUSEMOVE:
hdc = BeginPaint (hwnd, &ps) ;
TextOut (hdc, 10, 30, szBuff, lstrlen(szBuff));
EndPaint (hwnd, &ps) ;
return 0 ;
You should NEVER use BeginPaint() /EndPaint() outside of a WM_PAINT message
To get the dc do this:
HDC hdc = GetDC( hwnd );
//do painting
//release the DC
ReleaseDC( hwnd, hdc );
Try this it should fix the TextOut call
the diff between the two is in hte kinds of formatting options - also one will draw tab characters (and interpret them properly) while the other simply draws them as a glyph (which is why you'll see a big square character anywhere you have \t, \r, \n, etc
|
|
|
|
|
Hi Jim,
Thanks for reply.
Now Drawing text "Hello" at (10, 30) works.
I hope someone can answer my next question
i.e. drawing text "Hello" when moving curor on
client rect.
thanks
/rsasalm
|
|
|
|
|
A couple pointers:
- It is always a good idea to do all your drawing in your WM_PAINT handler, that way any drawing that you do is not lost when the window recieves a WM_PAINT message.
- If you are using TCHARs for strings, use the _tcs* functions (defined in tchar.h)
That said, what you should do is have to variables that store the coordinates where you want the string to be drawn. In your WM_MOUSEMOVE handler you change the values to the new coordinates, and then call RedrawWindow().
int x = 0, y = 0;
...
case WM_MOUSEMOVE:
x = LOWORD(lParam);
y = HIWORD(lParam);
RedrawWindow(hwnd, NULL, NULL, RDW_INVALIDATE | RDW_ERASE | RDW_UPDATENOW);
break;
case WM_PAINT:
hdc = BeginPaint (hwnd, &ps);
TextOut (hdc, x, y, szBuff, _tcslen(szBuff));
EndPaint (hwnd, &ps);
break;
...
<Edit - fixed syntax error in RedrawWindow call>
CPUA 0x5041
Sonork 100.11743 Chicken Little
"So it can now be written in stone as a testament to humanities achievments "PJ did Pi at CP"." Colin Davies
Within you lies the power for good - Use it!
|
|
|
|
|
Hi again,
Thanks for reply and now moving cursor with text "hellow" works fine.
I have one more question.
I found a function "GetCurrentPositionEx" with the following documentation:
*********************************
The GetCurrentPositionEx function retrieves the current position in logical coordinates.
BOOL GetCurrentPositionEx(
HDC hdc, // handle of device context
LPPOINT lpPoint // address of structure receiving current position
);
********************************
From documentation it seems to me that I could find the position of cursor as below:
case WM_LBUTTONDOWN:
POINT pt;
hdc = GetDC (hwnd) ;
GetCurrentPositionEx( hdc, &pt);
x = pt.x;
y = pt.y;
break;
But it doesn't work.
Am I missing something?
thanks for help
regards
/rsasalm
|
|
|
|
|
GetCursorPos() is used to get the current mouse cursor position on the screen.
GetCurrentPositionEx() is used to get the current text output position as set by TextOut() or ExtTextOut() after a call to SetTextAlign(hdc, TA_UPDATECP)
CPUA 0x5041
Sonork 100.11743 Chicken Little
"So it can now be written in stone as a testament to humanities achievments "PJ did Pi at CP"." Colin Davies
Within you lies the power for good - Use it!
|
|
|
|
|
how can i read barcode (or in general, port data) using c/c++?
thankx.
|
|
|
|
|
Did you try searching for "barcode" first? No, of course not. There is a series of articles that deal with it.
|
|
|
|
|
A CP sample has:
BOOL CADOTestDlg::DestroyWindow()
{
if ( (m_pConn->State & adStateOpen) == adStateOpen)
m_pConn->Close();
CoUninitialize();
return CDialog::DestroyWindow();
}
If I wanted to close in case the conn was open, I would just do:
if ( (m_pConn->State == adStateOpen)
m_pConn->Close();
Why do we have the & there? I tried to look up State on the MSDN but it didnt point me to the Connection State. For that matter doing F1 on Connection didnt land me in any databasey link either.
So I assumed State is the property which holds a particular value like open or closed or whatever.
So why do we have (m_pConn->State & adStateOpen) == adStateOpen
Thanks,'
ns
|
|
|
|
|
ns wrote:
So why do we have (m_pConn->State & adStateOpen) == adStateOpen
testing for a bit mask
|
|
|
|
|
it's a bitwise-AND it takes the bits from the left side and the bits from the right side, lines them up and does an AND on each pair.
-c
To explain Donald Knuth's relevance to computing is like explaining Paul's relevance to the Catholic Church. He isn't God, he isn't the Son of God, but he was sent by God to explain God to the masses. /. #3848917
|
|
|
|
|
I read about & and understand the math operation, but I'm trying to figure out in English what it accomplishes, if its possible.
Like if the right side is 010101, and the left side is 111111, then the result of & is 010101. This can also result from the left side being 01101 and many other such combinations. I just dont understand what it means. I dont even know if I should try....
Aaargh!
ns
|
|
|
|
|