|
Actually i want my programm to collect files in special directory, for example "c:\MyProgramm\Data", and my exe is in "c:\MyProgramm". But if someone canges the full path, where my programm placed?? For example:"c:\Program Files\MyProgramm\\"??? How to alway know where is the Application?
|
|
|
|
|
CString strApplicationDir;
char szPath[_MAX_PATH];
GetModuleFileName(NULL, szPath, _MAX_PATH);
strApplicationDir = szPath;
int nPos = strApplicationDir.ReverseFind('\\');
if (nPos != -1)
strApplicationDir = strApplicationDir.Left(nPos);
Michael
CP Blog [^]
|
|
|
|
|
|
Hi All,
How can I write to a file with random access, ie- be able to change data at any point in the file, not just append new data at the end?
I'm sure this must be possible, if you could give me a starter point / keyword i'm sure i'll be able to find the rest myself!
I don't want to "simulate" this by read/modify/write the whole file, because the files i need to modify will be in the 100's of megabytes!.
Thanks
Jon
#include <beer.h>
|
|
|
|
|
This may do what you want (http://www.codeproject.com/system/cfile64.asp)
In particular look at the Seek() function.
If you're not interested in files this big, have a look at the CFile class in MFC and in particular the Seek() function.
store your internet favourites online - www.my-faves.co.uk
|
|
|
|
|
OK, I've now figured this out.
Is there a way to insert data into the middle of a file? rather than overwrite it?
Thanks
#include <beer.h>
|
|
|
|
|
Not easily I'm afraid.
You need to get a copy of the data from the insertion point to the end of the file, insert your new data and then put back the rest of the file.
store your internet favourites online - www.my-faves.co.uk
|
|
|
|
|
Hi,
I'm writing a dialog by MFC.
I have several tabs, and every tab has some control items on it. I creat classes for every tab.
I want to send out status thru RS-232, such as when the user click one spin, and the spin value will be sent out thru RS-232.
My problem is I've got the tab class and a serial class ready. But how to confige a serial port that can be used by "all" tabs.
If I create the port in one tab's cpp, other tabs will not be able to use the port, of course.
However, it doesn't work if I configure a port in the project's main cpp, either.
Forthermore, if I call the functions in the CSerailPort class, like:
CSerialPort::Openport("com4");
The compiler says another error: illegal call of non-static member function.
Thanx your help.
Chauteen
|
|
|
|
|
Buddy,
if you are comfortable with pointer,then declare the pointer in base of CSerialPort like this is you class.
sorry i didn't work on tab control but i worked on property pages.i think you taleneted enough to understand this.
here is little solution,
you base class
CSerialPort *BasePort;
in your tabbed dialog classes as there can be many
CSerialPort *DerPort;
inbase class contructor or initdialog
BasePort=new CSerialPort;
//
function regrading insilization of port
///
now you are creating tab contral,
just pass the pointer to every derived tab classes
like this.
Let One of tab class is Ctab1;
now,
Ctab1.DerPort=this->BasePort;
andthis way you can access teh serial port in nay class.
ps,don't forget to delete the pointer before closing the application
-----------------------------
"I Think It will Work"
Formerly Known As "Alok The Programmer" at CP
-----------------------------
Alok Gupta
visit me at http://www.thisisalok.tk
|
|
|
|
|
Creating library ReleaseMinSize/ezrename.lib and object ReleaseMinSize/ezrename.exp
LIBCMT.lib(wwincrt0.obj) : error LNK2001: unresolved external symbol _wWinMain@16
I get this error message when I build in anything other than debug...it's an ATL COM object.
I figure it's a general C++ type question so I posted in here...
How to I fix this 'particular' linker error?
My local MSDN docs say check out MSKB article: Q125750
But it appears this is for dot net...not vc6 cuz I tried it and didn't get it to work...?
WTF...
TIA
How do I print my voice mail?
|
|
|
|
|
PRB: Error LNK2001: '_WinMain@16': Unresolved External Symbol
Si applica a
This article was previously published under Q125750
NOTE: Microsoft Visual C++ NET (2002) supported both the managed code model that is provided by the .NET Framework and the unmanaged native Windows code model. The information in this article applies to unmanaged Visual C++ code only.
SYMPTOMS
The linker generates the following error, when you build an MFC application with UNICODE support using the Microsoft products listed at the beginning of this article:
msvcrt.lib(crtexew.obj) : error LNK2001: unresolved external
symbol "_WinMain@16"
Visual C++ .NET:
error LNK2019: unresolved external symbol _WinMain@16 referenced in function _WinMainCRTStartup
fatal error LNK1120: 1 unresolved externals
CAUSE
MFC UNICODE applications use wWinMainCRTStartup as the entry point.
RESOLUTION
In the Output category of the Link tab in the Project Settings dialog box, set the Entry Point Symbol to wWinMainCRTStartup.
For Visual C++ .NET: In the Advanced category of the Linker folder in the Project Properties dialog box, set the Entry Point to wWinMainCRTStartup.
STATUS
This behavior is by design.
REFERENCES
The above information is documented in Books Online under this structure: - C/C++
- Programming Techniques
- Chapter 12 Developing for International Markets
- Support for Unicode
- Unicode Programming: Summary
This reference also lists the additional steps that you need to consider to take advantage of the MFC and C run-time support for Unicode.
|
|
|
|
|
I want to remove Close button "X" from the right corner of Dialog, but still want to keep the system menu at the left corner. Unchecking the system menu option from dialog properties also removes the menu at left.
Plz Help.
kriaz.
|
|
|
|
|
If you can't figure out that it's an non-trivial task to "remove" the close button entirely, your probably best just giving up.
Check CS_NOCLOSE in the WNDCLASS structure...I think that's as close as you'll get without some serious hacking (probably have to draw your own caption bar, non-client area, etc...lots of work!!!
p.s-I personally can't say I appreciate you announcing the fact he wasn't able to give you the answer you wanted. If you did that to me...i'd be choked!!!
How do I print my voice mail?
|
|
|
|
|
well, you posted your message on friday ... kind of a bad timing ...
and I don't know either.
Maximilien Lincourt
Your Head A Splode - Strong Bad
|
|
|
|
|
Bad form. David is a very knowledgable man. He has helped many people on this forum. And yes I include myself in the list.
Ant.
I'm hard, yet soft. I'm coloured, yet clear. I'm fruity and sweet. I'm jelly, what am I? Muse on it further, I shall return! - David Williams (Little Britain)
|
|
|
|
|
Well, since you're gonna act like that... I'll tell ya, but for a fee.
Now, if you want free advice, I suggest you quit whining like a spoiled brat. You'll improve your chances of getting it.
Jeremy Falcon
|
|
|
|
|
thanks in advance,
i am reading a file on a CD-ROM drive,
i first used CFile mfc library to read a file,
but it fails with Error Code (0x20) which is ERROR_BAD_UNIT
<br />
CFile aFile;<br />
aFile.Open("E:\\file.txt", CFile::modeRead | CFile::typeBinary)<br />
and
i also tested with FILE and fopen(...) , C library, it's ok
<br />
FILE *fp;<br />
fp = fopen("E:\\file.txt", "rb");<br />
what may be the problem ?
thanks again
|
|
|
|
|
Actually (0x20) is a hex number; you need to convert it to decimal.
32 ERROR_SHARING_VIOLATION - The process cannot access the file because it is being used by another process.
|
|
|
|
|
thanks first...
i changed my code to use CFileException as you mention
and found that m_cause gives me 11 which is
CFileException::sharingViolation : SHARE.EXE was not loaded, or a shared region was locked (msdn says...)
i think it's supposed to be working correctly though,
because when i read a file on a hdd, my app works fine
but when i changed target dir to CD-Rom, it fails with above reasons
may i miss something?
thanks
|
|
|
|
|
You can try to add CFile::shareDenyNone and see if that gets past the sharing issue.
|
|
|
|
|
i write follow code:
WCHAR cnt[100] = L"abc";
WCHAR* p = cnt;
wcscpy(p + 50, L"def");
i want print out "abc............def.....",but only get "abc"; "def" was lost.
someone may help me to resolve this problem?
|
|
|
|
|
hi
BSTR is capable of storing zero byte..
BSTR bs = ::SysAllocString(L"abc\0def" ); is valid.
i donno whether it will b a turning point for ur requirment.... try ..
for printing and all, i dont think it is possible... unless u write ur own custom printf or wsprintf.
rgds...mil10.
|
|
|
|
|
what about:
swprintf(outputbuf, L"%s%s", cnt, p+50);
|
|
|
|
|
hi all,
I have an ATL activeX DLL, I created my own file extension ( say .xyz) and made regisrty entries for opening test.xyz for the activeX control in the IE.
I objective is to render the contents of test.xyz into the broswer.
I am facing following problem.
How to pass the filename( test.xyz) when you double click on the file into the activeX control to render the file in IE.
I searched on CP but did'nt find anything related to it. may be i was on the wrong way. Can someone help me ?
Thanks in advance,
Abhi
|
|
|
|
|
hi all,
Found answer myself. may this be useful for someone.
1. Implement IPersistPropertyBagImpl interface for your class.
2. Override Load Method
Something like this:
<br />
STDMETHOD(Load)(IPropertyBag* pBag,IErrorLog *pErrorLog)<br />
{<br />
if(pBag == NULL)<br />
return E_POINTER;<br />
ATLASSERT(pBag);<br />
HRESULT hr = S_OK;<br />
CComVariant UrlString;<br />
hr = pBag->Read(L"src",&UrlString,pErrorLog);<br />
return S_OK;<br />
}<br />
In UrlString you will have the filename of the file on which you have clicked.
Thanks
Abhishake
|
|
|
|