|
We are running our c++ program as Windows services which uses JNI, . Program is getting CLASSPATH env variable correctly and also initializes JVM successfully. After initializing JVM, programs makes a JNI call FindClass() for getting java class.But FindClass method returns NULL even though java class exists in the CLASSPATH.
Same program when is run from command window, FindClass method call is working fine.
Is there any difference between running a program thru command window and as a windows service ?
Incase you have any idea on how to resolve this issue, kindly get back ASAP.
Best Regards,
sarathy
|
|
|
|
|
As a Windows service, your code is running under a different security context - for example, it is not an interactive user, it's running in a service logon. The difference here is that as an interactive user your process token includes the INTERACTIVE Security Identifier (SID), whereas as a service it instead includes the SERVICE SID.
The difference in SIDs or user accounts might lead to an access-denied error if the Access Control List on your class file is too strict. I suggest using SysInternals FileMon to investigate. See the SysInternals NT tools page[^].
|
|
|
|
|
i want to add an icon to a tree control but i can't. please tell me how can i do it .which section of this code is wrong?
CTreeControl m_tree;
CImageList img;
HICON hicon;
hicon=LoadIcon(IDR_MAINFRAME);
img->Add(AfxGetApp()->hicon);
m_tree.SetImageList(img, TVSIL_NORMAL);
|
|
|
|
|
First thing:
The SetImageList-call wants the pointer to an imagelist - but maybe that is a typo, as the compiler would be telling you that clearly.
Second thing:
Is it OK to let the ImageList-object you just introduced to the TreeCtrl go out of scope?
Maybe you need to make it a member?
Here is what I do (but note that I fill the imagelist with bitmaps!):
m_TreeImageList.DeleteImageList();
if(m_TreeImageList.Create(16,16,ILC_MASK,8,0))
{
std::vector<unsigned int> bmpId;
bmpId.push_back(IDB..);
bmpId.push_back(IDB..);
[...]
CBitmap bmp;
m_TreeImageList.SetBkColor(GetSysColor(COLOR_WINDOW));
for(unsigned int i = 0; i < bmpId.size(); ++i)
{
int b = bmp.LoadBitmap(bmpId[i]);
b = m_TreeImageList.Add(&bmp,(COLORREF)0xFFFFFF);
bmp.DeleteObject();
}
}
else
{
AfxMessageBox("ImageList Creation Failed!");
}
m_MyTree.SetImageList(&m_TreeImageList, TVSIL_NORMAL);
Who is 'General Failure'? And why is he reading my harddisk?!?
|
|
|
|
|
In addition to parameter one of SetImageList() needing to be a pointer, I'm not sure what you are trying to do with
img->Add(AfxGetApp()->hicon);
Clearly, CWinApp does not have a member named hicon, so I can only assume you meant
img->Add(hicon);
instead.
Five birds are sitting on a fence.
Three of them decide to fly off.
How many are left?
|
|
|
|
|
hi ,
how can i get all of the computer name&ip in local net work .I want to get other computer names&ip (All) ? how can i do ? do you understand me ? Can you help me ?
thank you !
|
|
|
|
|
my little suggestions:
char szhostname[128];
//gethostname
if( gethostname(szhostname, 128) == 0 )
{
// get ipaddr.
struct hostent * phost;
phost = gethostbyname(szhostname);
}
//and refer to msdn
Hello World!
|
|
|
|
|
not only my computer name & ip ! all in then local network .(some groups in the network)
|
|
|
|
|
i guess it's what about WNetOpenEnum.
See msdn.
Hello World!
|
|
|
|
|
see:
// TODO: Add extra validation here
CString strTemp;
struct hostent *host;
struct in_addr *ptr; // To retrieve the IP Address
DWORD dwScope = RESOURCE_CONTEXT;
NETRESOURCE *NetResource = NULL;
HANDLE hEnum;
WNetOpenEnum( dwScope, NULL, NULL,
NULL, &hEnum );
WSADATA wsaData;
WSAStartup(MAKEWORD(1,1),&wsaData);
if ( hEnum )
{
DWORD Count = 0xFFFFFFFF;
DWORD BufferSize = 2048;
LPVOID Buffer = new char[2048];
WNetEnumResource( hEnum, &Count,
Buffer, &BufferSize );
NetResource = (NETRESOURCE*)Buffer;
char szHostName[200];
unsigned int i;
for ( i = 0;
i < BufferSize/sizeof(NETRESOURCE);
i++, NetResource++ )
{
if ( NetResource->dwUsage ==
RESOURCEUSAGE_CONTAINER &&
NetResource->dwType ==
RESOURCETYPE_ANY )
{
if ( NetResource->lpRemoteName )
{
CString strFullName =
NetResource->lpRemoteName;
if ( 0 ==
strFullName.Left(2).Compare("\\\\") )
strFullName =
strFullName.Right(
strFullName.GetLength()-2);
gethostname( szHostName,
strlen( szHostName ) );
host = gethostbyname(strFullName);
if(host == NULL) continue;
ptr = (struct in_addr *)
host->h_addr_list[0];
// Eg. 211.40.35.76 split up like this.
int a = ptr->S_un.S_un_b.s_b1; // 211
int b = ptr->S_un.S_un_b.s_b2; // 40
int c = ptr->S_un.S_un_b.s_b3; // 35
int d = ptr->S_un.S_un_b.s_b4; // 76
strTemp.Format("%s --> %d.%d.%d.%d",
strFullName,a,b,c,d);
AfxMessageBox(strTemp);
}
}
}
delete Buffer;
WNetCloseEnum( hEnum );
}
WSACleanup();
//*******************************************
I try ,but fail ! thanks all the same !
|
|
|
|
|
Hellin wrote:
I try ,but fail !
Which tells us nothing. What exactly is failing? Are you getting a compiler/linker error. Is an assertion firing? Have you stepped through the code to see exactly what is (not) happening?
Five birds are sitting on a fence.
Three of them decide to fly off.
How many are left?
|
|
|
|
|
not code Error ,I say that ,only can search my own computer name &ip ,so i say I fail to !
|
|
|
|
|
What about my last question?
Five birds are sitting on a fence.
Three of them decide to fly off.
How many are left?
|
|
|
|
|
How to use them and which on earth to pick ?
Thank you , anyway!
Hello World!
|
|
|
|
|
This topic was discussed previously
The chosen One
|
|
|
|
|
which page?
Thank you very much!
Hello World!
|
|
|
|
|
Please see this[^] and this[^] thread. They will answer your question.
Who is 'General Failure'? And why is he reading my harddisk?!?
|
|
|
|
|
Hi,
does anyone know a possibility to mark code (.exe .dll) as unpageable!
to prevent windows from paging these code out of the memory.
Tanks,
Eddie
|
|
|
|
|
VirtualLock(), but if you have to ask then almost certainly you shouldn't be using it.
--
-Blake (com/bcdev/blake)
|
|
|
|
|
So does that mean that until a person learns how to use a function or an API, they shouldn't be using it? I'm curious how one goes about learning about something without first using it?
Five birds are sitting on a fence.
Three of them decide to fly off.
How many are left?
|
|
|
|
|
Not at all, you've over generalized. I said that about VirtualLock in particular not about API's in general.
Page locking memory is one of those things that is very seldom a good idea. The appropriate times for doing it usually occur in device drivers, and they use a different, kernel mode, API to accomplish this. Mostly people think they'll page lock parts of their application to 'improve performance' and that almost never works. Trust the memory manager to trim the working-set appropriately.
Off hand, the only legitimate reason I can think of for locking pages in a user-mode app is to prevent plaintext from being written to the pagefile in a crypto scenario, and I'm not positive it even guarentees that as expected.
Hence, unless you already know a _lot_ about how the Windows VM system works, you shouldn't be tampering with it, and if you don't know about VirtualLock then clearly you don't know enough about the VMM.
--
-Blake (com/bcdev/blake)
|
|
|
|
|
I am trying to call menu from dialog. That menu's ID is ID_MYMENU.
When you click on this button, it will do certain thing. what i
am trying to do is to call this ID_MYMENU from dialog and do the
same thing as when you click on the ID_MYMENU. I was thinking
to use function like SendMessage(ID_MYMENU,**,**) something like this.
Please help!
Shin
|
|
|
|
|
You don't need to call the menu from a button.
If you want more than 1 GUI object to be handled by the same code, then you should just edit the message maps to point to the same function.
|
|
|
|
|
If your dialog box is modal, it could be dangerous to activate a command of the application. Anyway, here's the syntax:
CMainFrame *pFrame = AfxGetApp()->m_pMainWnd;
pFrame->SendMessage(WM_COMMAND, ID_MYMENU);
Beware that with SendMessage, the call won't return before the execution of the command.
Silence Means Death
Stand On Your Feet
Inner Fear
Your Worst Enemy
|
|
|
|
|
Thank you very much. in this way, I can save a lot of
time. however, I will be carefull with those point you
mensioned.
Thanks, again.
Shin
|
|
|
|