|
Use full path names when specifying your files. The default file dialogs change the current directory.
"You're obviously a superstar." - Christian Graus about me - 12 Feb '03
"Obviously ??? You're definitely a superstar!!!" mYkel - 21 Jun '04
Within you lies the power for good - Use it! Honoured as one of The Most Helpful Members of 2004
|
|
|
|
|
The files I use internally are in directories that are in the same location as the program. IF someone moves the whole thing, how can I get the file path? I used "Directory1\file.txt" before, but how to get the whole path?
Thank you very much. I will try it manually to see if it will work. Thanks!
Kem
|
|
|
|
|
You can use GetModuleFileName() to get the path to the .exe. You can use that path to build your file paths.
"You're obviously a superstar." - Christian Graus about me - 12 Feb '03
"Obviously ??? You're definitely a superstar!!!" mYkel - 21 Jun '04
Within you lies the power for good - Use it! Honoured as one of The Most Helpful Members of 2004
|
|
|
|
|
Dear Sir,
Thank you VERY MUCH! It worked, and my program seems to be running ok. I really appreciate the help. If you're ever in the Philly area, let me know. I owe you a drink!
Kem
|
|
|
|
|
Rihannsu wrote:
If you're ever in the Philly area, let me know. I owe you a drink!
Just send cash;P
"You're obviously a superstar." - Christian Graus about me - 12 Feb '03
"Obviously ??? You're definitely a superstar!!!" mYkel - 21 Jun '04
Within you lies the power for good - Use it! Honoured as one of The Most Helpful Members of 2004
|
|
|
|
|
I'm working on a program that reads a small text file (from AppPath) every x seconds, and is always running on the computer. Since most computers are always on, should I keep that x value as low as possible to reduce wear on the hard drive (and maximize laptop battery life), or is that not really a problem? I currently have x set at 5 seconds, and could go as long as 60 seconds.
|
|
|
|
|
If you are waiting for the file to change some how you may be better off using this[^] approach.
"You're obviously a superstar." - Christian Graus about me - 12 Feb '03
"Obviously ??? You're definitely a superstar!!!" mYkel - 21 Jun '04
Within you lies the power for good - Use it! Honoured as one of The Most Helpful Members of 2004
|
|
|
|
|
Doh, can't believe I didn't think of that . Thanks!
I actually decide to use FindFirstChangeNotification, because it supports 98/ME.
|
|
|
|
|
People that use power management (eg laptops) will not be happy with that method, because the constant disk access will prevent the computer from going into power-saving mode (stand-by/hibernate).
--Mike--
Visual C++ MVP
LINKS~! Ericahist | 1ClickPicGrabber | CP SearchBar v2.0.2 | C++ Forum FAQ
Strange things are afoot at the U+004B U+20DD
|
|
|
|
|
My problem is that I have to read the content of a web page which is dynamic (written in PHP), and the content is always different. I read the content using the following code :
<br />
void CHS_VCDlg::Onread() <br />
{<br />
CString URL = "http://www.eed.usv.ro/~pentiuc/hs2005/index.php";<br />
CInternetSession session;<br />
m_Result += "Trying " + URL + "\r\n";<br />
UpdateData(FALSE);<br />
CInternetFile* file = NULL;<br />
try<br />
{<br />
file = (CInternetFile*) session.OpenURL(URL);<br />
}<br />
catch (CInternetException* pEx)<br />
{<br />
file = NULL;<br />
pEx->Delete();<br />
}<br />
if (file)<br />
{<br />
m_Result += "Connection established. \r\n";<br />
CString line;<br />
for (int i=0; i < 20 && file->ReadString(line); i++)<br />
{<br />
m_Result += line + "\r\n";<br />
}<br />
file->Close();<br />
delete file;<br />
}<br />
else<br />
{<br />
m_Result += "No server found there. \r\n";<br />
}<br />
m_Result += "------------------------\r\n";<br />
UpdateData(FALSE);<br />
}<br />
It works well, but the problem is that I have to clear the cache and the cookies all the time from Internet Explorer.
I want to know if there a way to clear the cache and the cookies by code in order to read the new content of the page every time I call this function??
Croitoriu Andrei
croi2001@yahoo.com
|
|
|
|
|
|
I tried ti use DeleteUrlCacheEntry() and even found a more complete function:
<br />
#include <wininet.h><br />
BOOL DelTempFiles()<br />
{<br />
BOOL bResult = FALSE;<br />
BOOL bDone = FALSE;<br />
LPINTERNET_CACHE_ENTRY_INFO lpCacheEntry = NULL;<br />
<br />
DWORD dwTrySize, dwEntrySize = 4096;
HANDLE hCacheDir = NULL;<br />
DWORD dwError = ERROR_INSUFFICIENT_BUFFER;<br />
<br />
do<br />
{<br />
switch (dwError)<br />
{<br />
case ERROR_INSUFFICIENT_BUFFER:<br />
delete [] lpCacheEntry;<br />
lpCacheEntry = (LPINTERNET_CACHE_ENTRY_INFO) new char[dwEntrySize];<br />
lpCacheEntry->dwStructSize = dwEntrySize;<br />
dwTrySize = dwEntrySize;<br />
BOOL bSuccess;<br />
if (hCacheDir == NULL)<br />
<br />
bSuccess = (hCacheDir<br />
= FindFirstUrlCacheEntry(NULL, lpCacheEntry,<br />
&dwTrySize)) != NULL;<br />
else<br />
bSuccess = FindNextUrlCacheEntry(hCacheDir, lpCacheEntry, &dwTrySize);<br />
<br />
if (bSuccess)<br />
dwError = ERROR_SUCCESS;<br />
else<br />
{<br />
dwError = GetLastError();<br />
dwEntrySize = dwTrySize;
}<br />
break;<br />
<br />
case ERROR_NO_MORE_ITEMS:<br />
bDone = TRUE;<br />
bResult = TRUE;<br />
break;<br />
<br />
case ERROR_SUCCESS:<br />
<br />
if (!(lpCacheEntry->CacheEntryType & COOKIE_CACHE_ENTRY))<br />
<br />
DeleteUrlCacheEntry(lpCacheEntry->lpszSourceUrlName);<br />
<br />
dwTrySize = dwEntrySize;<br />
if (FindNextUrlCacheEntry(hCacheDir, lpCacheEntry, &dwTrySize))<br />
dwError = ERROR_SUCCESS;<br />
<br />
else<br />
{<br />
dwError = GetLastError();<br />
dwEntrySize = dwTrySize;
}<br />
break;<br />
<br />
default:<br />
bDone = TRUE;<br />
break;<br />
}<br />
<br />
if (bDone)<br />
{<br />
delete [] lpCacheEntry;<br />
if (hCacheDir)<br />
FindCloseUrlCache(hCacheDir);<br />
<br />
}<br />
} while (!bDone);<br />
return bResult;<br />
}<br />
I tried to use this function but I get the following errors:
<br />
--------------------Configuration: HS_VC - Win32 Debug--------------------<br />
Compiling...<br />
HS_VCDlg.cpp<br />
Linking...<br />
HS_VCDlg.obj : error LNK2001: unresolved external symbol __imp__FindCloseUrlCache@4<br />
HS_VCDlg.obj : error LNK2001: unresolved external symbol __imp__DeleteUrlCacheEntry@4<br />
HS_VCDlg.obj : error LNK2001: unresolved external symbol __imp__FindNextUrlCacheEntryA@12<br />
HS_VCDlg.obj : error LNK2001: unresolved external symbol __imp__FindFirstUrlCacheEntryA@12<br />
Debug/HS_VC.exe : fatal error LNK1120: 4 unresolved externals<br />
Error executing link.exe.<br />
<br />
HS_VC.exe - 5 error(s), 0 warning(s)<br />
<br />
Can anyone tell me why do I get those errors ? What is wrong... where is my mistake?
Please help me...
Croitoriu Andrei
croi2001@yahoo.com
|
|
|
|
|
|
I am trying clear a Cstring variable null. I tried NULL, didnt work.
I tried '\0' , worked but i can't append anything to the cstring.
I just need to make cstring variable blank(or clear it) and when user presses the number buttons, they are appended to the cstring variable.
Thanks in advance.
-hithesh
|
|
|
|
|
CString str;
str = _T("");
"You're obviously a superstar." - Christian Graus about me - 12 Feb '03
"Obviously ??? You're definitely a superstar!!!" mYkel - 21 Jun '04
Within you lies the power for good - Use it! Honoured as one of The Most Helpful Members of 2004
|
|
|
|
|
Thanks. I just used quotes and it worked.
-hithesh
|
|
|
|
|
|
Two more cstring question-
How do I determine the length?
How do I compare individual elements of a cstring?
I am trying to find out the number of digits entered after the decimal point in a floating point number like 2.33
-hithesh
|
|
|
|
|
hithesh wrote:
How do I compare individual elements of a cstring?
CString::GetAt()
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
|
|
|
|
|
did you watch this ????
CString::length() -> returns the length of the string
if you like to compare 2 elements, you can use either operator[] () or GetAt() ...
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
I am trying to get the Text Object Model interfaces to work, but it seems that some of the functions simply do not work right.
According to the docs the ITextRange interface has a method called ITextRange::GetPoint() which, supposedly, will return the x,y coordinates of the range. You can specify a flag that is made of a series of bit flags that tell the function what the coords are for (the start or end) and whether you want the top, bottom, left/right, or baseline, center.
However no matter what you send in, the fucntion always returns E_FAIL as a HRESULT value. Does anyone have any experience using these API's? I'd love to be able to get this to work.
¡El diablo está en mis pantalones! ¡Mire, mire!
Real Mentats use only 100% pure, unfooled around with Sapho Juice(tm)!
SELECT * FROM User WHERE Clue > 0
0 rows returned
Save an Orange - Use the VCF!
|
|
|
|
|
I have a series of structures overlayed with a buffer (fields and buffer of a message). This is in shared memory
Can someone tell me why the first method I use to set fields in a message do not work correctly.
Setting the time tag causes the year data to be wrong - data seems to be 8 bytes wide, even if you cast it to unsigned short.
typedef struct{<br />
unsigned long Msg001_02_01_spare1_w01 : 2;<br />
unsigned long Msg001_02_01_msg_code_valid : 1;<br />
unsigned long Msg001_02_01_msg_status : 1;<br />
unsigned long Msg001_02_01_spare2_w01 : 4;<br />
unsigned long Msg001_02_01_spare3_w01 : 8;<br />
unsigned short Msg001_02_02_time_time_tag;<br />
unsigned long Msg001_02_03_year_1000_s : 4;<br />
unsigned long Msg001_02_03_year_100_s : 4;<br />
unsigned long Msg001_02_03_year_10_s : 4;<br />
unsigned long Msg001_02_03_year_1_s : 4;<br />
unsigned long Msg001_02_04_day_10_s : 4;<br />
unsigned long Msg001_02_04_day_1_s : 4;<br />
unsigned long Msg001_02_04_month_10_s : 4;<br />
unsigned long Msg001_02_04_month_1_s : 4;<br />
unsigned long Msg001_02_05_hour_10s : 4;<br />
unsigned long Msg001_02_05_hour_1s : 4;<br />
unsigned long Msg001_02_05_minute_10s : 4;<br />
unsigned long Msg001_02_05_minute_1s : 4;<br />
unsigned long Msg001_02_06_second_10s : 4;<br />
unsigned long Msg001_02_06_second_1s : 4;<br />
unsigned long Msg001_02_06_second_0_1s : 4;<br />
unsigned long Msg001_02_06_second_0_01s : 4;<br />
}Msg001_02;<br />
<br />
struct TSharedMemory {<br />
union<br />
{<br />
Msg001_02 fields;
unsigned short buffer[32];
}Msg001_02;<br />
<br />
etc ...<br />
};<br />
<br />
TSharedMemory *g_pRigMem;
<br />
etc ..
If I use the following code to set the time tag it affects the year data:-
g_pRigMem->Msg001_02.fields.Msg001_02_02_time_time_tag = (unsigned short)timeMilseconds;
Even the following does the same:-
g_pRigMem->Msg001_02.buffer[1] = (unsigned short)timeMilseconds;
also the following code seems to do the same for fields in the next word?
g_pRigMem->Msg001_02.fields.Msg001_02_03_year_1000_s = year1000s;<br />
g_pRigMem->Msg001_02.fields.Msg001_02_03_year_100_s = year100s;<br />
g_pRigMem->Msg001_02.fields.Msg001_02_03_year_10_s = year10s;<br />
g_pRigMem->Msg001_02.fields.Msg001_02_03_year_1_s = year1s;
If however I set the void* to the location of the data in the shared memory and use the following code it works OK
<br />
if(m_sFieldType == "unsigned short")<br />
{<br />
*(unsigned short *) fieldPtr = (unsigned short)(timeMilseconds);<br />
}
and for bit fields:-
<br />
*(char *) fieldPtr = (char)(bitField);
This sets the data OK and the years data is OK.
Can someone explain why the first method causes the problem.
Many thanks,
Graham.
grahamfff
|
|
|
|
|
Grahamfff wrote:
unsigned long Msg001_02_01_spare3_w01 : 8;
unsigned short Msg001_02_02_time_time_tag;
unsigned long Msg001_02_03_year_1000_s : 4;
I would make the time tag the same format as the rest
unsigned long Msg001_02_02_time_time_tag : 16;
Maybe also pack the structure and union to 1 byte boundaries using #pragma pack(1) . You could be running into alignment problems.
"You're obviously a superstar." - Christian Graus about me - 12 Feb '03
"Obviously ??? You're definitely a superstar!!!" mYkel - 21 Jun '04
Within you lies the power for good - Use it! Honoured as one of The Most Helpful Members of 2004
|
|
|
|
|
Hi, i need for my final project to make a software that compress file, but i don't know where to start , if someone know something about this, pls help me, i need it.
thanks
Jackie.
|
|
|
|
|
You need to start by figuring out what algorithm you want/need to use. Huffman, LZW ... Then you can search this site for examples. Then if you do not find what you need there is always google.
John
|
|
|
|