|
i need to invoke a jvm, but i don't know why FindClass() returns 0.
i think it's about class.path settings or the name of the class i'm trying to access.
what do i have to put in class.path? the path of my java class or the path of jdk?
do java class and .exe have to be in the same directory?
help me please, thanks!!
here is my code:
// ============= java class ============ //
package embedding;
// ...
public static void main(String[] args)
{
MyClass prova = new MyClass();
prova.run();
}
// ============= c++ code ============ //
//...
options[0].optionString = "-Djava.class.path=C:\\aa\\MyClass"; // the directory path where my java class is saved
//...
//cls = env->FindClass("C:/aa/MyClass");
cls = env->FindClass("MyClass");
|
|
|
|
|
hii...i am transferrin the resources from one exe to another....
also i am saving the resources as a .rc using the Resource Hacker software...which replaces the existing .rc file of the project.....
but i am getting the following error:-
"error RC 2019 : expected preprocessor command, found '1' "
(the error gigving line is-- #106 MENU)
this one is due to the id of the MENU resource i hav trasnferred from another exe
the next error is:- "RC Terminating after preprocessor errors"
how can i solve this?
is ther another way pf updating the .rc or .res files of a projetc using VC++ programming ?
regards,
kedar.
|
|
|
|
|
Numeric resource IDs in an .rc file are just numbers. A # symbol introduces a preprocessor command (such as #include, #ifdef, etc). Delete the # and you should be fine.
You can open an .rc file in Visual Studio, then drag and drop resources from it to the Resources tab of your project. Hold Ctrl to copy resources rather than move (which is, bizarrely, the default).
Stability. What an interesting concept. -- Chris Maunder
|
|
|
|
|
hii...i removed the '#' from the code but aftrwards i got the following errors:-
1)Primary Language Id is not a number
2)WS_**** undeclared/undefined (for the transferred resource)
how can i solve these errors?
regards,
kedar.
|
|
|
|
|
is there any API other than URLDownLoadTocachefile() to download a file in asynchronous mode(user shouldnot be blocked)
|
|
|
|
|
|
I suppose you could always download the file in a separate thread, then the user's primary thread would not be blocked.
|
|
|
|
|
I'm using some hotkeys (which are there in the accelerator table). The hotkeys are working fine when I build and run the exe in Debug mode, but If I try the Release exe, the application just crashes by by giving a runtime error and saying that 'The instruction at"0x77de6439" referenced memory at "0x0036ad38". The memory could not be "read".'
Is it that I need to do something special to make the accelerator table available to the Release exe? or something else which I may have missed?
|
|
|
|
|
Have you done a complete rebuild? It's the only think I can think of.
"If I don't see you in this world, I'll see you in the next one... and don't be late." ~ Jimi Hendrix
|
|
|
|
|
Yes, I've done the complete rebuild many times and still getting the same error.
Thanx, anyway, for your time.
|
|
|
|
|
|
I would like to create an application that does not appear in the Windows Task manager and system Try or any other means that might detect its existance
|
|
|
|
|
I have no idea how you can do that, but I'm curious as to why you would like to do that?
"If I don't see you in this world, I'll see you in the next one... and don't be late." ~ Jimi Hendrix
|
|
|
|
|
I don't think that you can hide your application completely, but you can definitely hide it enough so the average user won't find it.
If you don't show the main window of your application "ShowWindow(SW_HIDE)" then you won't have an entry on the taskbar. It will however be visible in task manager.
If you don't want it in the task manager you'll have to make a service of your application. (search for 'service' on CP and you'll find a bunch of articles on how to do this...)
In the event viewer you'll still be able to see that your service is started, but I guess the average user won't go looking there.
Hiding your app from the user might not be a nice thing to do as they have a right to know what's going on...
Don't think you are, know you are...
|
|
|
|
|
Mohsen Saad wrote:
I would like to create an application that does not appear in the Windows Task manager
this article may help you out
http://www.codeproject.com/system/preventclose.asp
Mohsen Saad wrote:
system Try
-->Usually no app show there existence in System Tray ,you have to write
code for making App ICON Visible in System Tray.
or if you are looking for about Window Taskbar :- Create Window with WS_EX_TOOLWINDOW EXTENDED style.
"I Think this Will Help"
[Vote One Here, Complete my Survey....]
<h5
alok="" gupta="" <br=""> visit me at http://www.thisisalok.tk
|
|
|
|
|
You should not be hiding it - there is a very strong backlash building against these sort of applications.
|
|
|
|
|
I agree. The only exception I can think of at this point would be a "customized desktop" like you might have at a school or a library. CBT kiosks are a good example, too.
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
i am designing a GUI soft and wanna minimize it to taskbar,users can do some simple functions on the taskbar window.
what i saying is just like Microsoft MediaPlay 8,9,10.
i want to konw how to realize the operation.
ThankS!!
Stick to C++
|
|
|
|
|
I've tried the DRAWCLI sample from MSDN
it uses c++ polymorphism for its
implementation
why all tool's instance pointer are stored in the variable c_tools(CPtrList)
thanks in advance
|
|
|
|
|
I am experiencing problem regarding calling a "PostThreadMessage" function from outside the thread function. A code is attched below... Please go through it and guide me as to how to go about correcting it...
/*
The PRODUCER and OTHER threads post messages to the
CONSUMER thread. All the threads wait on the
"consumerReady" event to be set by the main thread.
*/
#include
#include
#include
typedef struct temp
{
int msid;
char *msg;
}box;
// Thread IDs. Define these globally so the threads can refer to each other.
DWORD producerID, consumerID, otherID;
void get_msg(DWORD quid,box *obj);
void post_msg(DWORD quid,box *obj);
// An event
HANDLE consumerReady;
// The producer thread.
DWORD WINAPI produce(LPVOID)
{
// Do not start producing until all threads are ready.
WaitForSingleObject(consumerReady, INFINITE);
int count = 0;
while(count < 2)
{
box *ptr;
ptr=(box *)malloc(sizeof(box));
ptr->msg = (char *)malloc(10);
strcpy(ptr->msg,"hello\0");
ptr->msid = 12;
post_msg(consumerID,ptr);
// PostThreadMessage(consumerID, WM_USER, (WPARAM)ptr, 0); // works fine if this
// line is used instead
// of above line
Sleep(1000);
printf("\nposted 12");
count++;
}
return 0;
}
// The consumer thread.
DWORD WINAPI consume(LPVOID)
{
// Do not start producing until all threads are ready.
WaitForSingleObject(consumerReady, INFINITE);
Sleep(0);
int count = 0;
while (true)
{
box *ptr;
ptr=(box *)malloc(sizeof(box));
ptr->msg = (char *)malloc(10);
get_msg(consumerID,ptr);
count++;
printf("count %d",count);
}
return 0;
}
DWORD WINAPI other(LPVOID)
{
// Do not start producing until all threads are ready.
WaitForSingleObject(consumerReady, INFINITE);
int count = 0;
// Send simple integers. Use WM_USER messages with the integer values
// in the wParam field.
while(count < 2)
{
box *ptr;
ptr=(box *)malloc(sizeof(box));
ptr->msg = (char *)malloc(10);
strcpy(ptr->msg,"other\0");
ptr->msid = 11;
post_msg(consumerID,ptr);
// PostThreadMessage(consumerID, WM_USER, (WPARAM)ptr, 0); // works fine if this
// line is used instead
// of above line
Sleep(1000);
printf("\nposted 11");
count++;
}
return 0;
}
// main() runs the simulation.
int main()
{
// Create an event which is initially unsignaled
consumerReady = CreateEvent(0, TRUE, FALSE, 0);
// Create the threads and start them immediately.
HANDLE consumerHandle = CreateThread(0, 0, consume, 0, 0, &consumerID);
HANDLE producerHandle = CreateThread(0, 0, produce, 0, 0, &producerID);
HANDLE otherHandle = CreateThread(0, 0, other, 0, 0, &otherID);
//Set the event now that all threads are ready
SetEvent(consumerReady);
//Keep the main thread alive
WaitForSingleObject(producerHandle, INFINITE);
WaitForSingleObject(consumerHandle, INFINITE);
return 0;
}
void post_msg(DWORD quid,box *obj)
{
PostThreadMessage(quid, WM_USER, (WPARAM)obj, 0);
int err = GetLastError();
printf("\n obj_post->msgid %d ",obj->msid);
printf("\n err_post = %d ",err);
}
void get_msg(DWORD quid,box *obj)
{
MSG lmsg;
GetMessage(&lmsg, 0, 0, 0);
obj = (box*)(lmsg.wParam);
int err = GetLastError();
printf("\n obj_get->msgid %d ",obj->msid);
printf("\n obj_get->msg %c ",*(obj->msg));
printf("\n err_get = %d ",err);
}
///////////////////////////////////////////////////////////////////////
The output is given below:
obj_post->msgid 12
err_post = 1444
obj_post->msgid 11
err_post = 1444
posted 12
obj_get->msgid 12
obj_get->msg h
err_get = 0 count 1
posted 11
obj_get->msgid 11
obj_get->msg o
err_get = 0 count 2
obj_post->msgid 11
err_post = 1444
obj_post->msgid 12
err_post = 1444
posted 11
posted 12
////////////////////////////////////////////////////////////
As can be seen , posting the messages results in a error id of 1444(INVALID THREAD IDENTIFIER) which is puzzling cos all the threads are already created....
Any help would be appreciated in this regard...
|
|
|
|
|
Do it like this ...........
Change
DWORD WINAPI consume(LPVOID)
{
WaitForSingleObject(consumerReady, INFINITE);
Sleep(0);
int count = 0;
while (true)
{
box *ptr;
ptr=(box *)malloc(sizeof(box));
ptr->msg = (char *)malloc(10);
get_msg(consumerID,ptr);
count++;
printf("count %d",count);
}
return 0;
}
to
DWORD WINAPI consume(LPVOID)
{
MSG msg;
box* test;
WaitForSingleObject(consumerReady, INFINITE);
Sleep(0);
while (true)
{
get_msg(consumerID,test);
}
return 0;
}
And change
void get_msg(DWORD quid,box *obj)
{
MSG lmsg;
GetMessage(&lmsg, 0, 0, 0);
obj = (box*)(lmsg.wParam);
int err = GetLastError();
printf("\n obj_get->msgid %d ",obj->msid);
printf("\n obj_get->msg %c ",*(obj->msg));
printf("\n err_get = %d ",err);
}
to
void get_msg(DWORD quid,box *obj)
{
MSG lmsg;
GetMessage(&lmsg, 0, 0, 0);
obj = (box*)malloc( sizeof(box)*1);
obj->msid = 0;
obj->msg = (char *)malloc(10);
memset(test->msg,'0',10);
obj = (box*)(lmsg.wParam);
int err = GetLastError();
printf("\n obj_get->msgid %d ",obj->msid);
printf("\n obj_get->msg %c ",*(obj->msg));
printf("\n err_get = %d ",err);
}
|
|
|
|
|
I'm reading data from the serial port with ReadFile(). Now I know that in the middle of the read, I will get a null character (0x00). After the ReadFile statement, the string it's put the characters into only exists until the null character, thinking that position is the null terminating the string, but there's more data that it read past that null which I need. Previously, I'd read one character at a time, if it was a null, it would toss it out. If it wasn't null, it'd copy it to a string. That works but it's too complicated and takes too much time communicating with the serial port. Anyone have an idea I can bypass this null but not have to read each character one at a time. When reading one character at a time, there are some really sticky and annoying timing issues that quickly turn into a minefield for me so any way I can avoid it is fine with me. Thanks in advance, Nate.
|
|
|
|
|
It's not because there is a null character in your string that the rest of your data isn't read from the serial port.
What you can do is read the data (all at once) in to a char[] and then copy character per character into a string if you want to...
Something like this:
int i, index=0;
char DataBuffer[], StringBuffer[];
ReadFile(...)
for (i=0; i < NumberOfBytesRead; i++)
{
if (DataBuffer[i] != '\0')
StringBuffer[index++] = DataBuffer[i];
}
This way you don't have to worry about communication timing and so on.
Don't think you are, know you are...
|
|
|
|
|
That's kind of what I was doing, but I was reading in a byte at a time instead of reading them all in one step, then copy the character if it wasn't null. But that looks pretty sharp though, good call, thanks.
|
|
|
|
|
Since the buffer can contain '\0' characters, you cannot use any string-related functions like strlen() or strcpy() . You'll need to use memcpy() instead if you need to transfer data from one variable to another.
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|