|
Hi All
How can i check path is exits or not in system(pc)?plz give me Api or function name?
Thanks is advance
|
|
|
|
|
|
i got solution from msdn.
(_access(path,0)==0)
|
|
|
|
|
Hello Davitor,
You can use function - PathFileExists()[^].
Regards,
Jijo.
_____________________________________________________
http://weseetips.com[ ^] Visual C++ tips and tricks. Updated daily.
|
|
|
|
|
You can use of FindFirstFile.
Of one Essence is the human race
thus has Creation put the base
One Limb impacted is sufficient
For all Others to feel the Mace
(Saadi )
|
|
|
|
|
Also look at GetFileAttributes() (Which I used just yesterday!)
(One problem with FileExists() is that it returns true for both files and directories.)
Anyone who thinks he has a better idea of what's good for people than people do is a swine.
- P.J. O'Rourke
|
|
|
|
|
hi every one
I create a static library with visual c++ 6.0 App wizard.
I create a new generic class and declared my variables in its header file.
Then I initialized my variables in class constructor.
I want to use it in a new dialog based project, so I add related header file and write my library name in linker tab at project setting.
I create one object of this class in my function, But at the end of function when application exits from function occurs an exception.
I can't handle this exception.
Note : when I comment initialized this exception don’t happen.
Please help me
////////////////////////////////////////////////////////////////
// static library class (Test.h)
///////////////////////////////////////////////////////////////
class CTest
{
public:
CTest();
virtual ~CTest();
int m_i1;
int m_i2;
bool m_b1;
bool m_b2;
unsigned int m_ui1;
unsigned int m_ui2;
unsigned short m_us1;
unsigned short m_us2;
BYTE m_bte1;
BYTE m_bte2;
CString m_str1;
CString m_str2;
};</afx.h></windef.h>
#include "stdafx.h"
#include "Test.h"
CTest::CTest()
{
m_i1=0;
m_i2=0;
m_b1=true;
m_b2=true;
m_ui1=0;
m_ui2=0;
m_us1=1;
m_us2=1;
m_bte1=0;
m_bte2=0;
m_str1="";
m_str2="";
}
CTest::~CTest()
{
}
////////////////////////////////////////////////////////////////
// My dialog base application
///////////////////////////////////////////////////////////////
void CUseTestLibDlg::OnBinitlib()
{
CTest *pcTest=new CTest();
delete pcTest;
pcTest=NULL;
}
void CUseTestLibDlg::OnBinitlib2()
{
CTest pcTest;
}
modified on Wednesday, April 29, 2009 6:26 AM
|
|
|
|
|
samira forooghi wrote: pcTest=NULL;
delete pcTest;
I would invert the order of the statements...
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]
|
|
|
|
|
thanks for u
i correct it ,but its not my problem.
|
|
|
|
|
Looks like good advice...
Steve
|
|
|
|
|
Shouldn't cause an accvio, though - you can delete NULL in C++.
|
|
|
|
|
but will result in a memory leak.
This signature was proudly tested on animals.
|
|
|
|
|
I didn't say it wouldn't - I was just saying that fixing it wouldn't solve the OP's problem.
|
|
|
|
|
|
Yes, but Carlo just indicated one of flaws in the OP's code. I agree that it wouldn't solve 'the problem' of the OP, but it might (hopefully) prevent the OP from shooting his own face sometime in the future.
It is a crappy thing, but it's life -^ Carlo Pallini
|
|
|
|
|
i havent any problem with new delete , occur exception even this case
void CUseTestLibDlg::OnBinitlib2()
{
CTest pcTest;
}
|
|
|
|
|
The problem's obviously in CTest's destructor. The only significant activity in CTest's destructor will be calls to m_str1's and m_str2's destructors. Therefore, the access violation is happening somewhere in there.
I suspect there's something not quite right with your project settings - check that the library and main app are using hte same MFC and C run-time library settings.
|
|
|
|
|
I have just started at a new job. Here we are new to using JNI ( for bridging C++ / Java ). I am new to JNI so please forgive my noobness
In our (win32) Java app we are loading a C++ DLL. On the Java side we have several instances of "SomeJClass" each of these instances needs access to corresponding instance of "SomeCClass" on the DLL side. The DLL exposes entry-points such as GlobalDoSomethingInC(). Here I must call the instance method of Doer::DoSomethingInC(). So I need a smooth way to map the respective this-pointers. I also need to do the same mapping when a DLL thread discovers something interesting that it needs to notify the corresponding Java-instance of.
I can think of several solutions, but I do not like them too much. My question is, is there a better way than this ?
1 Java calls C:GetNewInstance(). This returns an int that is actually a pointer to the new C instance. Java stores it in m_myCInstance. Then Java calls GlobalDoSomethingInC(), and 1a
void GlobalDoSomethingInC()<br />
{<br />
jobj tmpJ = NewGlobalRef( env, obj );<br />
Doer* myDoer = <reinterpret_cast>( Doer )tmpJ->GetMyCInstance();<br />
myDoer->DoSomething();<br />
DeleteGlobalRef( env, tmpJ );<br />
}<br />
</reinterpret_cast>
1b or:
Doer* myDoer = <reinterpret_cast>( Doer )instanceParam->DoSomethingInC();<br />
<br />
</reinterpret_cast> 2 For calling from C to Java, things look, maybe, better
In the constructor C calls back into Java and stores
the Java instance reference
in a member variable. m_myJInstance.<br />
In all subsequent calls m_myJInstance can be used to call back Java.<br />
In the destructor we need to call DeleteGlobalRef( env, m_myJInstance );<br />
Not too bad I suppose. But it really safe to store the jobject reference. I mean: What happens when the GC moves the object around?
3 Our present solution does "work". But it belongs on rather on http://www.codinghorror.com/blog/
Another question, for JNI experts only. How much juice does it cost to do this sequence:
<br />
jobj tmpJ = NewGlobalRef( env, obj );<br />
tmpJ->GetMyCInstance();<br />
DeleteGlobalRef( env, tmpJ );
Thanks
Adam
........................
Life is too shor
|
|
|
|
|
I have a MDI application which has several document types. And I am adding sub-menus dynamically for some of the document types. The follwoing is the code snippet
class CMyMenu: public CMenu
{
int data1;
...
public:
virtual ~CMyMenu(){};
};
Then in the mainframe I declare a function AddNewMenu
CMainFrame::AddMenu(HMENU hMenu)
{
CMyMenu *pMenu = (CSMenu*)CSMenu::FromHandle( toolbarMenu );
CMyMenu* popup1 =
new CSMenu(), *popup2 = new CSMenu();
//create the two pop-up menus
createPopup1(&popup1);
createPopup2(&popup2);
pMenu ->AppendMenu( MF_POPUP, (UINT)popup1->GetSafeHmenu(), "Popup1" );
pMenu ->AppendMenu( MF_POPUP, (UINT)popup2->GetSafeHmenu(), "Popup2" );
...
}
My question is if I call ::DestroyMenu(hMenu) later on, it will delete all the submenus but will it delete the associated "CMyMenu" objects too or do I have to save both popup1 and popup2 to delete the objects my self
Please reply
Thanks
|
|
|
|
|
Farhat Aisha wrote: My question is if I call ::DestroyMenu(hMenu) later on, it will delete all the submenus but will it delete the associated "CMyMenu" objects too or do I have to save both popup1 and popup2 to delete the objects my self
Well I guess you can either choose to believe the documentation, or not. If you don't believe it then you can perform some tests to see if it leaks.
DestroyMenu[^]
Remarks
Before closing, an application must use the DestroyMenu function to destroy a menu not assigned to a window. A menu that is assigned to a window is automatically destroyed when the application closes.
DestroyMenu is recursive, that is, it will destroy the menu and all its submenus.
|
|
|
|
|
Hi,
Actually i need to vanish the 'X'-box from the system menu & keep only Minimize-Box in the menu bar.
I'hv used a code stuff under OnInitDialog()---
CMenu* cmenu = this->GetSystemMenu(FALSE);
cmenu->ModifyMenu(SC_CLOSE,MF_BYCOMMAND | MF_GRAYED);
OR
CMenu* cmenu = GetSystemMenu(FALSE);
cmenu ->RemoveMenu(SC_CLOSE,MF_BYCOMMAND );
cmenu ->RemoveMenu(0,MF_BYPOSITION);
==>In both cases ,it only disabling the X-box not vanishing from the menu bar.
So is there any way to totally clear this X-box.
If then plz repay as soon as possible.
Thanks in advance
|
|
|
|
|
You could modify the code in this article[^] (see the PaintCap.h and PaintCap.cpp files in the file linked from the article) to draw the title-bar yourself. That way you can decide exactly which boxes to draw...
|
|
|
|
|
Shashi.Shinde wrote: So is there any way to totally clear this X-box.
Not without removing the entire system menu, or drawing it yourself.
"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
|
|
|
|
|
|
Please rephrase your query such that people can understand it. Also, the 'bold' font face doesn't particularly look charming.
It is a crappy thing, but it's life -^ Carlo Pallini
|
|
|
|