|
I don't know it as well but... as you are giving a reference to the CCriticalSection in the constructor of your CSingleLock, I guess you can access its methodes from the second one as well. It maybe is so to create an object based in one type and having access to functions in both (created and referenced).
Let see what the others say. (BTW, nice question )
Greetings.
--------
M.D.V.
If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about?
Help me to understand what I'm saying, and I'll explain it better to you
“The First Rule of Program Optimization: Don't do it. The Second Rule of Program Optimization (for experts only!): Don't do it yet.” - Michael A. Jackson
|
|
|
|
|
The purpose of CSingleLock is to prevent cases where you might accidentally do this
<br />
<br />
mySection.Lock();<br />
....<br />
<br />
return;<br />
<br />
mySection.Unlock();<br />
<br />
If you use CSingleLock then when return is called CSingleLock is destroyed and its destructor calls Unlock() preventing disaster.
"The secret of happiness is freedom, and the secret of freedom, courage."
Thucydides (B.C. 460-400)
|
|
|
|
|
Hi,
I am trying to call a java class from vc++ program.I had added the jvm.lib in project setting. Also used loadlibrary or afxloadlibrary to load the jvm.dll. but while i am running that ,before the control comes in the initinstance of app class it is showing following error.
"The application has failed to start because jvm.dll was not found"
So basically the loadlibrary is not getting chance to load the dll as the error is ocuuring before control comes to the iniinstance function .
So i am confused how to use jvm.dll.
My code is
JavaVM* jvm;
JNIEnv* env;
JavaVMInitArgs args;
JavaVMOption options[1];
args.version = JNI_VERSION_1_4;
args.nOptions = 1;
options[0].optionString = "-Djava.class.path=C:\\Asset Migration\\converter";
args.options = options;
args.ignoreUnrecognized = TRUE;//JNI_FALSE;
AfxMessageBox("JVM start");
int res =JNI_CreateJavaVM(&jvm, (void **)&env, &args);
if(res<0)
{
AfxMessageBox("JVM failed");
return TRUE;
}
jclass cls = env->FindClass("TestJNI");
jmethodID mid = env->GetStaticMethodID(cls, "dis", "(I)V");
env->CallStaticVoidMethod(cls, mid, 100);
|
|
|
|
|
intermediate wrote: I had added the jvm.lib in project setting. Also used loadlibrary or afxloadlibrary to load the jvm.dll.
If you link with jvm.lib the your application will perform load-time linking with jvm.dll (hence you have to call neither AfxLoadLibrary nor LoadLibrary ). Anyway you have to make sure that jvm.dll can be found by the loader, see [^].
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
|
|
|
|
|
Mmmm, if the *.lib has a header, and it is included as well you don't need to use LoadLibrary (), do you?
Greetings.
--------
M.D.V.
If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about?
Help me to understand what I'm saying, and I'll explain it better to you
“The First Rule of Program Optimization: Don't do it. The Second Rule of Program Optimization (for experts only!): Don't do it yet.” - Michael A. Jackson
|
|
|
|
|
CPallini wrote: (hence you have to call neither AfxLoadLibrary nor LoadLibrary) .
Maybe my English is misleading (I supposed neither and nor doing the trick of negation).
Anyway, to state it clearly:
If you use load-time DLL linking (i.e. the import library *.lib in the project) then you don't need AfxLoadLibrary (and you don't need LoadLibrary as well).
Is it OK now?
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
|
|
|
|
|
I cannot keep the jvm.dll in the application path.It need to be in the install path.Also though i had declared the #include "jni.h" but if i don't include jvm.lib in setting then it gives linking error.
So how loader will find the dll in the installed path.As normally loader finds it in the exe path.
|
|
|
|
|
MSDN [^] states the loader will search also in folders specified by the PATH environment variable:
6. The directories that are listed in the PATH environment variable. Note that this does not include the per-application path specified by the App Paths registry key. The App Paths key is not used when computing the DLL search path.
Hence you can augment PATH , adding jvm.dll folder.
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
|
|
|
|
|
I need optimised hash table code implementted in C++ for my project.Can any body post me the source code?
fawadNaseeem
modified on Thursday, May 15, 2008 11:12 PM
|
|
|
|
|
Hi.
I want to understand that which program is using my dll. Can dll understand itself or , another program.Anybody have idea about this.
|
|
|
|
|
No reason why your Dll can't call GetStartupInfo[^]. That should get you at least the basic information you're after.
"The secret of happiness is freedom, and the secret of freedom, courage."
Thucydides (B.C. 460-400)
|
|
|
|
|
Hi experts,
I have an activex control that is placed on a dialog. At runtime I have the nIDs of all the controls so, by using function GetDlgItem I am able to get the pointer to that activex control as CWnd*.
So, My question is how can I get that activex class name or how can i identify whether the pointer is of activex class or not. I have already used typeid, CRuntimeClass, and dynamic_cast but unable to get the required result.
Please help me in resolving it.
Regards,
Pankaj Sachdeva
There is no future lies in any job but future lies in the person who holds the job
|
|
|
|
|
I can't see why GetRuntimeClass wouldn't work for ordinary controls and dynamic_cast to IUnknown wouldn't work for Ax Controls. Just be prepared to handle the exceptions when you try the wrong one. I have no idea why you'd want to do this anyway, don't you know which controls are ActiveX control already, having put them on the dialog
"The secret of happiness is freedom, and the secret of freedom, courage."
Thucydides (B.C. 460-400)
|
|
|
|
|
Hi,
Have you tried CObject::IsKindOf ?
Regards,
Paresh.
|
|
|
|
|
How do I get the size of any file that I am reading in VC++.
ifstream myfile;
myfile.open(path);
THANKS
|
|
|
|
|
Is it to solve this problem? If yes, please use the registry or an ini file to store your application related information. Those APIs exist for this very purpose.
Nobody can give you wiser advice than yourself. - Cicero
.·´¯`·->Rajesh<-·´¯`·.
Codeproject.com: Visual C++ MVP
|
|
|
|
|
and you're going to delete your question once someone replied to you ?
check the CFile class for any File related operations...
|
|
|
|
|
toxcct wrote: and you're going to delete your question once someone replied to you
Well said.
|
|
|
|
|
Have you considering using GetFileSize() or GetFileAttributesEx() ?
"Love people and use things, not love things and use people." - Unknown
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
long file_len;
ifstream myfile;
myfile.open(path);
myfile.seekg(0, ios::end);
file_len = myfile.tellg();
myfile.close();
------------------------------------------
variable file_len's value is file length.
|
|
|
|
|
hai all masters,
here is my problem.
i want to access a hardware device(server) through TCPIP.
i know its ip address, and i want to write an application(client) to access it. but i donot know the port number.
is there any way to access it with out knowing the port number?
if any more clarity is required, then i can provide.
please give your views on this.
thanks in advance.
|
|
|
|
|
chandu004 wrote: is there any way to access it with out knowing the port number?
Of course:
(1) choose randomly a port
(2) are you able to communicate with the device?
(3) if the answer is yes then you're a lucky guy.
(4) if the answer is no, goto point 1.
That's called Montecarlo TCP/IP .
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
|
|
|
|
|
thanks pallini,
of course i have tried that before posting it here. i tried from 0 to 10000. but no use
any way let me provide you more details such that, you can help me.
1.the device is access control system(card swipe system) in our office.
2.the vendor has provided his software, which will download the swpe logs to the PC.
3.for some reasons, i wanted to have my own software for that.
so, i did the following things.
1.i made a session in hyperterminal using tcpip with the device ip and default port number 23.
2.then the device responded with welcome note, version number and a login prompt at my hyperterminal.
3.so here, i under stood that, i have to provide some username and pwd.
so i tried to simulate the server(the device) through my application and communicate with his software and find the username and pwd.
but the application is unable to communicate with my simulator.
any ideas on this?
please excuse me members, if my post is a bit lengthy.
|
|
|
|
|
I was just kidding, of course. Why don't you issue the netstat command (from command prompt) while the device is connected with vendor software to see involved ports?
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
|
|
|
|
|
wov thats wonderful. i was exactly looking for such a tool.
but it gives me the results all at a time. not in real time.
i mean, if i start it, and then start his application from another system, then it(netstat) should show me the commands that got transfered from one port to other.
any way, i shall look into the options of it and get back to you.
or if you have any idea of such an application then please forward me its url.
thanks for the clue.
|
|
|
|