|
thanks, it is working now. i will bother u soon if i stuck in something.
one more thing i want to ask. currently i have only one computer so no network. will this program work on a network of computers too ? i cant check myself.
suppose i run it on a client, will it give the info of server or all the computers in the network (clients + servers) ?
also, if i have the ip address of the server then how to use it in this program ?
thanks again
rahul
update :
when i make a try to make a array of processes like this -------
wchar_t selPro[] = { _T("W3SVC"), _T("Iisadmin")};
SC_HANDLE hService = OpenService(hSCM, selPro[j], SERVICE_QUERY_STATUS);
where j is for "for" lool (0,1). when i compile this code, compiling completes without any error and when i try to run it, it crashes. if i pass without array, it works fine.
please guide me
modified on Saturday, June 13, 2009 5:05 PM
|
|
|
|
|
rahuljin wrote: will this program work on a network of computers too ?
That's what NetServerEnum() is for.
rahuljin wrote: suppose i run it on a client, will it give the info of server or all the computers in the network (clients + servers) ?
First, did you try it? Second, did you check MSDN to see how OpenSCManager() handles its first argument?
rahuljin wrote: also, if i have the ip address of the server then how to use it in this program ?
Convert the IP address to the host name using gethostbyaddr() .
rahuljin wrote: ...it crashes.
Meaning what? A "crash" is fairly meaningless.
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
here is error from windows. it says "new01" has stopped working
Problem signature:
Problem Event Name: APPCRASH
Application Name: new01.exe
Application Version: 0.0.0.0
Application Timestamp: 4a349ab0
Fault Module Name: RPCRT4.dll
Fault Module Version: 6.1.7100.0
Fault Module Timestamp: 49eea681
Exception Code: c0000005
Exception Offset: 0002f3b0
OS Version: 6.1.7100.2.0.0.256.1
Locale ID: 16393
Additional Information 1: 0a9e
Additional Information 2: 0a9e372d3b4ad19135b953a78882e789
Additional Information 3: 0a9e
Additional Information 4: 0a9e372d3b4ad19135b953a78882e789
Read our privacy statement online:
http:
If the online privacy statement is not available, please read our privacy statement offline:
C:\Windows\system32\en-US\erofflps.txt
here is the complete code of the program ----
#ifndef UNICODE
#define UNICODE
#endif
#include <stdio.h>
#include <assert.h>
#include <windows.h>
#include <lm.h>
#include <tchar.h>
#include <wchar.h>
void printServer(LPSERVER_INFO_101 ppTmpBuf, DWORD ddwEntriesRead)
{
SC_HANDLE hSCM;
SERVICE_STATUS ss;
DWORD i;
short int j, x;
x = 2;
wchar_t* prName[] = {
_T("W3SVC"),
_T("Themes")
};
for (i = 0; i < ddwEntriesRead; i++)
{
for(j=0; j<x ; j++)
{
hSCM = OpenSCManager((LPCTSTR) ppTmpBuf->sv101_name,
NULL, SC_MANAGER_CONNECT);
if (hSCM != NULL)
{
SC_HANDLE hService = OpenService(hSCM, prName[j], SERVICE_QUERY_STATUS);
if (hService != NULL)
{
if (QueryServiceStatus(hService, &ss) != FALSE)
{
if ((ss.dwCurrentState == SERVICE_RUNNING)||(ss.dwCurrentState == SERVICE_START_PENDING))
wprintf(_T("%-20s %-15s This service is running.\n"),ppTmpBuf->sv101_name, prName[j]);
else
wprintf(_T("%-20s %-15s This service is stopped or not found.\n"),ppTmpBuf->sv101_name, prName[j]);
}
CloseServiceHandle(hService);
}
}
CloseServiceHandle(hSCM);
}
ppTmpBuf++;
}
NetApiBufferFree(ppTmpBuf);
}
void debugeFunct(NET_API_STATUS nState, LPSERVER_INFO_101 pTmpBuf,
DWORD dwEntriesRead, DWORD dwTotalEntries)
{
NET_API_STATUS nas ;
NET_DISPLAY_MACHINE * pndm;
DWORD dwNdmCount;
switch(nState)
{
case NERR_Success:
case ERROR_MORE_DATA:
{
if(pTmpBuf == NULL)
{
fprintf(stderr, "An access voilation has occurred.\n");
}
else
{
nas = NetQueryDisplayInformation (pTmpBuf->sv101_name,
2,
0,
1,
sizeof(NET_DISPLAY_MACHINE),
&dwNdmCount,
(PVOID*)&pndm);
switch (nas)
{
case NERR_Success:
case ERROR_MORE_DATA:
printServer(pTmpBuf, dwEntriesRead);
break;
default:
{
printf("NQDI gave error %u\n", nas);
break;
}
}
}
}
break;
default:
printf("No pc were found. The buffer returned was NULL\n");
break;
}
NetApiBufferFree(pTmpBuf);
}
void findServ(DWORD dwPrefMaxLen, DWORD dwServerType)
{
LPSERVER_INFO_101 pBuf = NULL;
DWORD dwLevel = 101;
DWORD dwEntriesRead = 0;
DWORD dwTotalEntries = 0;
DWORD dwTotalCount = 0;
DWORD dwResumeHandle = 0;
NET_API_STATUS nStatus;
LPTSTR pszServerName = NULL;
LPTSTR pszDomainName = NULL;
nStatus = NetServerEnum(
(LPCWSTR) pszServerName,
dwLevel,
(LPBYTE *) & pBuf,
dwPrefMaxLen,
&dwEntriesRead,
&dwTotalEntries,
dwServerType,
(LPCWSTR) pszDomainName,
&dwResumeHandle
);
debugeFunct(nStatus, pBuf, dwEntriesRead, dwTotalEntries);
NetApiBufferFree(pBuf);
}
int _tmain(int argc, wchar_t * argv[])
{
DWORD dPrefMaxLen = MAX_PREFERRED_LENGTH;
DWORD dServerType = SV_TYPE_SERVER;
printf("Machine Service Status\n");
while(1)
{
findServ(dPrefMaxLen, dServerType);
Sleep(3000);
}
return 0;
} Here is the event viewer file of the application
modified on Sunday, June 14, 2009 10:33 AM
|
|
|
|
|
So where's the problem?
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
when i remove the following statements from the program, program run without any error.
NetApiBufferFree(ppTmpBuf);
NetApiBufferFree(pTmpBuf);
what may be the problem with this ?
|
|
|
|
|
rahuljin wrote: what may be the problem with this ?
It appears you are freeing the same memory three times.
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
yes, that may be the reason for the program crash.
is there a way to access from a client if it have minimum access ? i mean that the client can access only a few folder in the other pc.
also when i try this program on xp OS system, it gives the error ---
NetQueryDisplayInformation gave error ERROR_ACCESS_DENIED.
Due to this error, it does not display the status of service even of the system it is running on. it is a client pc.
though i can ping the ip of other computers in the network.
is there any remedy for this ?
modified on Tuesday, June 16, 2009 3:50 AM
|
|
|
|
|
from the Win32 console functions built CreateDialog,use
only dos.h, conio.h, stdio.h.I using VC6
by tuan1111.Vietnam
|
|
|
|
|
|
Are you some kind of troll ? Do you really think that somebody will be able to answer any of your questions ?
|
|
|
|
|
The random word generator you have used for this and your previous posts is working perfectly.
If you have developed it yourself you should really post an article about it!
|
|
|
|
|
Hello,
I have an ActiveX control that provides such method:
void GetCurrentImage(long theFormat, VARIANT * theBuffer, long * theBufferSize);
I want to get a byte image buffer from this function. That is, I am trying to do this:
long image_size;
VARIANT FrameBuf[1024*1024];
char ByteBuf[1024*1024];
pCtrl->GetCurrentImage(0, FrameBuf, &image_size);
I did some googling. But partly because VARIANT is a common word that confused Google, I can hardly find any useful solution to this. Can anyone give me some advice? Thank you very much.
Jason
|
|
|
|
|
Creating an array of Variant is wrong.
Try this
VARIANT FrameBuf;
BYTE ByteBuf[1024 * 1024];
FrameBuf.vt = VT_BYREF|VT_UI1;
FrameBuf.pbVal = ByteBuf;
pCtrl->GetCurrentImage(0, FrameBuf, ℑ_size);
«_Superman_»
I love work. It gives me something to do between weekends.
|
|
|
|
|
_Superman_,
Thank you for your kindly reply. I guess you were meaning this, right?
pCtrl->GetCurrentImage(0, &FrameBuf, &size);
since GetCurrentImage() takes a VARIANT* argument.
But after I executed your example code(with GetCurrentImage line replaced with the above one) and checked the ByteBuf, I found its content is unchanged. Did I still miss anything here?
Thanks,
Jason
|
|
|
|
|
Please check the return value of GetCurrentImage to see if it has succeeded.
«_Superman_»
I love work. It gives me something to do between weekends.
|
|
|
|
|
Unfortuenately, the function is an asyncrous function and returns immediatly, so return value is not useful. I have waited quite some time in the main thread and the check result is the same: the image size is returned correctly, but the buffer is unchanged...
|
|
|
|
|
Hey guys,
I couldn't find the way to display '&' on CMFCToolBarButton. I have a string of "Boy&Girl" and I want to display that string on a CMFCToolBarButton. If I set its text to exactly "Boy&Girl", the text will be displayed as "BoyGirl" due to a window control shortcut.
So.. I replace the original, "Boy&Girl" to "Boy&&Girl" so that I can display '&' character. However, I ended up with Boy Girl".
Now I replace the orignal text with "Boy/&Girl", it displays my text as "Boy Girl".
Do you guys know how to fix this?
Thanks!
Un
|
|
|
|
|
Un Suthee wrote: "Boy&Girl"
Try "Boy&&Girl".
It is a crappy thing, but it's life -^ Carlo Pallini
|
|
|
|
|
I tried that but it does not work.
The problem is I am using CMFCToolBarButton::OnDraw() method.
I looked at the source code of that function and turns out that it does not set a flag "DT_NOPREFIX" in which tells DrawText not to interpret ampersand as a directive to underscore the following character.
So the work around I did is to convert a string "Boy&Girl" to "Boy&&&&Girl" !! What happens is CMFCToolBarButton::OnDraw() will convert this string to "Boy&&Girl" and then CDC::DrawText will now convert "&&" to "&". It works but I guess there must be a much better solution than the one I have.
Thanks!
Un
|
|
|
|
|
Un Suthee wrote: Now I replace the orignal text with "Boy/&Girl"
You should try "Boy\&Girl". Backslash instead of forward slash.
But I guess your workaround is pretty good.
«_Superman_»
I love work. It gives me something to do between weekends.
|
|
|
|
|
You should try "Boy\\&&Girl". Backslash instead of forward slash.
I think so it's ok.
|
|
|
|
|
I just tried "Boy\\&&Girl" and I got "Boy\Girl".
Un
|
|
|
|
|
I do not know too,for I am a beginner. haha
Keep running slowly but never stop.
|
|
|
|
|
hi
I am getting error
Unhandled exception at 0x0037bbae in abc.exe: 0xC0000005: Access violation writing location 0x000000a8.
I debugged and it looks like the error happens at a function call.
argMainLoop( MouseEvent, keyEvent, mainLoop );
the three arguments are three functions.
declaration:
void argMainLoop( void (*mouseFunc)(int button, int state, int x, int y),
void (*keyFunc)(unsigned char key, int x, int y),
void (*mainFunc)(void) )
I check the disassembly.
argMainLoop( MouseEvent, keyEvent, mainLoop );
0043DE9F push offset mainLoop (43E410h)
0043DEA4 push offset keyEvent (43DF90h)
0043DEA9 push offset MouseEvent (43DF60h)
0043DEAE call @ILT+4420(_argMainLoop) (436149h)
0043DEB3 add esp,0Ch
the crash is happening at last two lines of the assembly.
The functions that are passed as parameters are all forward declared. all the declarations looked fine(else might have been compiler issue). the error is coming up in run time in debug and release configurations.
I am stuck here with no idea how to proceed in identifying the error. Any hints would be very helpful
|
|
|
|
|
How are declared and defined the callback functions?
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|