|
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
|
|
|
|
|
I ned to detect moment when all operation on
Creation and Showing window is finished,
and window ready to work and working ?
Also what message window receives when othr window moves
over it ?
Thanks
|
|
|
|
|
vgrigor wrote:
Creation and Showing window is finished,
and window ready to work and working ?
I dont think there is a any that kinda message, but there is a workaround for this...
If i assume that you are talking about dialog window.
You need to do the following steps.
1.Define a custom window
#define WM_MYMESSAGE WM_USER + 1
2.Then at the end of the OnInitDialog you post this message
PostMessage(WM_MYMESSAGE,0,0);
3. Add a message handler for the message in the message map.
...
ON_MESSAGE(WM_MYMESSAGE,OnMyMessage)
...
4. Implement the function.
MSN Messenger.
prakashnadar@msn.com
"If history isn't good, just burn it." - Sidhuism.
|
|
|
|
|
I had a similar problem when starting up a program (Acrobat Reader) and wanted to wait until it had finished convulsing before trying to diddle it. I stumbled upon WaitForInputIdle() . Here is a working example of using it:
STARTUPINFO startupInfo;
PROCESS_INFORMATION processInfo;
::ZeroMemory(&startupInfo, sizeof(startupInfo));
startupInfo.cb = sizeof(startupInfo);
::ZeroMemory(&processInfo, sizeof(processInfo));
char cmd[MAX_PATH + MAX_PATH + 5];
sprintf(cmd,"\"%s\" \"%s\"", szExe, pdfFile);
BOOL startedOK = CreateProcess(
NULL,
cmd,
NULL,
NULL,
FALSE,
0,
NULL,
NULL,
&startupInfo,
&processInfo);
if(!startedOK)
{
ShowLastError(cmd);
return;
}
<big>WaitForInputIdle(processInfo.hProcess,INFINITE);</big>
Of course, this is assuming the windows you're interested in are in another process...
|
|
|
|
|
Imagine, if such a mad people will decide how to
hang on real people really ?
(Biting infinite)
average dog is better. Only want to bite once.
|
|
|
|
|
i guess PeekMessage can be used for this purpose.
Gurmeet S. Kochar
If you believe in God, it's because of the Devil
|
|
|
|
|
I developed an database application using VC++ and Micorsoft Access driver as the ODBC source. There are 2 threads in the application both accessing the same table. The first thread writes data in the table and the second thread reads and deletes data from the table. Here is a snapshot of the code of the second thread:
while (!attackRecSet->IsEOF())
{
.
.
.
.
.
.
try
{
attackRecSet->Delete();
attackRecSet->MoveNext();
} //try
catch(CDBException *e)
{
MessageBox(NULL, e->m_strError, "Error", MB_OK);
e->Delete();
} //catch
} //while
An error message occurs because of the delete function and the thread stops working. the error message is:
" Could not update; currently locked by user 'admin' on machine ISLAM_COMPUTER'. "
and when I press OK the following message occurs for ever (it reoccurs if I press the OK button):
" Invalid cursor position; no keyset defined. "
If I commented the delete function the thread will work perfectly. I searched the MSDN for an explanation but with no use. Could anyone tell where could I find an explanation for this error.
Islam Hegazy
islam
|
|
|
|
|
You need to use syncronization objects like Mutex or CriticalSection to ensure that only one thread works with the database system.
MSN Messenger.
prakashnadar@msn.com
"If history isn't good, just burn it." - Sidhuism.
|
|
|
|
|