|
Yes, but why would you want to? As you add items to the array, memory is allocated from the heap to hold the individual items. The array object itself consumes very little memory.
"The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)
|
|
|
|
|
My guess is he wants it to exist outside the scope of the creating block.
/ravi
My new year's resolution: 2048 x 1536
Home | Articles | Freeware | Music
ravib@ravib.com
|
|
|
|
|
Simple:
CArray<int> *theArray = new CArray<int>;
theArray->Add(1);
theArray->Add(42);
theArray->SetAt(0, 1337);
Or am I missing something?
Remember, even if you win the rat race, you're still a rat.
|
|
|
|
|
Hi guys
I've got this
CString file;
HANDLE hFile = CreateFile( ?????,........
What I have to put in ????? to get a valid value in hfile,all my tries have finished with a -1.
LPCSTR(file) doesn't work and I don't know what to do.
Thanks
Doc
|
|
|
|
|
|
Already read,but sorry, I can't see the solution.
My question is, how can I convert a CString to the right parameter to the CreateFile method?
Thanks
Doc
|
|
|
|
|
CString strFile = _T("C:\\myfile.txt");
HANDLE hFile = CreateFile (strFile, GENERIC_WRITE, 0, NULL, CREATE_NEW, 0, NULL);
/ravi
My new year's resolution: 2048 x 1536
Home | Articles | Freeware | Music
ravib@ravib.com
|
|
|
|
|
Sorry, it has been my fault.
My problem comes maybe from the point that I can't assign my file directly putting double \\.
// My Code
TCHAR m_szDrive[10];
TCHAR m_szDir[MAX_PATH];
TCHAR m_szFullPath[MAX_PATH];
CString sFile;
// Application Path
::GetModuleFileName(NULL,m_szFullPath,MAX_PATH);
_splitpath(m_szFullPath,m_szDrive,m_szDir,NULL,NULL);
sFile=m_szDrive;
sFile+=m_szDir;
sFile+=_T("myfile.txt");
CreateFile(sFile,.... THAT DOESN'T WORK
Do you know how can I convert my string to the right parameter?
Thanks for your patience.
Doc
|
|
|
|
|
TCHAR* pSlash = NULL;
TCHAR szFilespec [_MAX_PATH];
::GetModuleFileName (AfxGetInstanceHandle(), szFilespec, _MAX_PATH);
pSlash = _tcsrchr (szFilespec, _T('\\'));
ASSERT (pSlash != NULL);
pSlash++;
*pSlash = _T('\0');
CString strFilename = szFilespec + _T("myFile.txt");
hFile = Create (strFilename, ...)
/ravi
My new year's resolution: 2048 x 1536
Home | Articles | Freeware | Music
ravib@ravib.com
|
|
|
|
|
I've corrected
error C2110: cannot add two pointers
CString strFilename = szFilespec + _T("myFile.txt");
but still same problem sorry
Doc
|
|
|
|
|
CString strFilename = szFilespec;
strFilename += _T("myFile.txt");
/ravi
My new year's resolution: 2048 x 1536
Home | Articles | Freeware | Music
ravib@ravib.com
|
|
|
|
|
As I said in my last post, I've already corrected this compiler error and still the same problem.
Sorry
Doc
|
|
|
|
|
This works,
<br />
TCHAR m_szDrive[10];<br />
TCHAR m_szDir[MAX_PATH];<br />
TCHAR m_szFullPath[MAX_PATH];<br />
CString sFile; <br />
::GetModuleFileName(NULL,m_szFullPath,MAX_PATH);<br />
_splitpath(m_szFullPath,m_szDrive,m_szDir,NULL,NULL); <br />
sFile=m_szDrive;<br />
sFile+=m_szDir;<br />
sFile+=_T("myfile.txt");<br />
HANDLE h = ::CreateFile ( sFile,<br />
GENERIC_WRITE,<br />
FILE_SHARE_READ,<br />
NULL,<br />
OPEN_ALWAYS,<br />
FILE_ATTRIBUTE_NORMAL,<br />
NULL ) ;<br />
Given that your code appears to compile the problem is probably down to the arguments to 'CreateFile'. What are you using?
Paul
|
|
|
|
|
Anybody out there have this very frustrating problem?:
When I build my project, Visual often hangs and I have to kill the Visual C++.NET process and start over. It happens on a regular basis and the "Stop build" button does not work. It is very frustrating!!!
|
|
|
|
|
when accessing from another process.
All variables have not null values.
void getMenuItem(HWND hWndMenu)
{
HMENU menu = GetMenu(hWndMenu);
MENUITEMINFO mi, *_mi; unsigned long pid;
HANDLE process;
GetWindowThreadProcessId(hWndMenu, &pid);
process=OpenProcess (PROCESS_VM_OPERATION|PROCESS_VM_READ|PROCESS_VM_WRITE|PROCESS_QUERY_INFORMATION, FALSE, pid);
_mi=(MENUITEMINFO*)VirtualAllocEx(process, NULL, sizeof(MENUITEMINFO), MEM_COMMIT, PAGE_READWRITE);
ZeroMemory(&mi, sizeof(MENUITEMINFO));
mi.cbSize = sizeof(MENUITEMINFO);
mi.fMask = MIIM_TYPE;
mi.fType = MFT_STRING;
mi.dwTypeData=NULL;
WriteProcessMemory(process, _mi, &mi, sizeof(MENUITEMINFO), NULL);
// this fails GetMenuItemInfo(menu, 1, true, _mi);
ReadProcessMemory(process, _mi, mi, sizeof(MENUITEMINFO), NULL);
int size = mi.cch;
VirtualFreeEx(process, _mi, 0, MEM_RELEASE);
|
|
|
|
|
I have an app that I recently opened a copy of in .Net to try to finish with .Net capabilities. Everything works fine so far, except that when I close the app, I get the following error message:
Unhandled exception at 0x00130276 in FB.exe: 0xC0000005: Access violation reading location 0x0099139c.
It's indicating the Bolded line in the following function (which I have never touched):
CRichEditCntrItem* CRichEditView::GetInPlaceActiveItem() const
{
ASSERT(m_lpRichEditOle != NULL);
CRichEditDoc* pDoc = GetDocument();
CRichEditCntrItem* pItem = NULL;
CReObject reo;
HRESULT hr = m_lpRichEditOle->GetObject(REO_IOB_SELECTION, &reo,
REO_GETOBJ_ALL_INTERFACES);
if (GetScode(hr) == S_OK && (reo.dwFlags & REO_INPLACEACTIVE))
{
pItem = pDoc->LookupItem(reo.poleobj);
if (pItem == NULL)
pItem = pDoc->CreateClientItem(&reo);
ASSERT(pItem != NULL);
}
return pItem;
}
Does anyone have any idea what's the problem? I'm very new to .Net and have no clue.
If it's broken, I probably did it
bdiamond
|
|
|
|
|
I have two VB apps in which I need to send a PeopleID from one app to another. If the 2nd app is closed, I could probably just specify it as a command-line argument. But what if the app is already running? Is there a way that I can do this in a dll?
If it's broken, I probably did it
bdiamond
|
|
|
|
|
Hi. I'm looking for some hints (code) that will allow me add new rules to OE and add new Folder.
Thanks
Pain is a weakness living the body
|
|
|
|
|
Hi,
I have wrote a progrm that process word documents. I want to skip processing the password protected word documents.
How to find a word document is password protected, with out opening the document?
Thanks,
GTS
GTS
|
|
|
|
|
If you are using Word's COM interface (i.e., automation), then any attempt at opening a file with a missing/invalid password will fail. You can use such a return code to know whether to skip the file or not.
"The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)
|
|
|
|
|
Hi
Using either Add method or Open method not causes the failure, it simply stalls the execution. Any idea?
Thanks,
GTS
|
|
|
|
|
Please mention the programming language you are using.
Gurmeet S. Kochar
If you believe in God, it's because of the Devil
|
|
|
|
|
Hi,
I am using VC++ and COM library of MS Word.
Thanks,
GTS
|
|
|
|
|
Hi, I need to extract every information I can from ADSL modem(speed,SRN..) (best using tellnet). How to do this or what functions to use? Thanks in advance.
|
|
|
|
|
I doubt that you can. While dialup modems have de facto standards for communications (the Hayes AT command set) I have been unable to find any such common interface for ADSL modems. Of the dozen or so that I've used, no two used the same command line interface (CLI) - the cheaper ones didn't even have one, relying entirely on a built in web page for setting and retrieving configuration information. If you discover such a standard it would make for a great article here, though!
Will Build Nuclear Missile For Food - No Target Too Small
|
|
|
|