Click here to Skip to main content
15,898,222 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: convert string to ascii in vc++ Pin
ThatsAlok18-Mar-05 1:05
ThatsAlok18-Mar-05 1:05 
GeneralRe: convert string to ascii in vc++ Pin
nehathoma18-Mar-05 1:10
nehathoma18-Mar-05 1:10 
GeneralRe: convert string to ascii in vc++ Pin
ThatsAlok18-Mar-05 2:22
ThatsAlok18-Mar-05 2:22 
GeneralRe: convert string to ascii in vc++ Pin
nehathoma18-Mar-05 16:56
nehathoma18-Mar-05 16:56 
QuestionPowerpoint Automation: VB a lot faster than C++ ?? Pin
User 172888417-Mar-05 22:53
User 172888417-Mar-05 22:53 
GeneralFindFirstUrlCacheEntry problem Pin
Spiritofamerica17-Mar-05 22:45
Spiritofamerica17-Mar-05 22:45 
GeneralRe: FindFirstUrlCacheEntry problem Pin
Michael Dunn18-Mar-05 8:22
sitebuilderMichael Dunn18-Mar-05 8:22 
GeneralRe: FindFirstUrlCacheEntry problem Pin
Mike Dimmick18-Mar-05 8:49
Mike Dimmick18-Mar-05 8:49 
The INTERNET_CACHE_ENTRY_INFO structure displays two common Windows API features. It contains a structure size member (dwStructSize) for versioning purposes - compatibility can be maintained if further fields are later added. The declared structure also does not completely describe the returned data - in fact the structure is only a header, with more data following on.

I think you're getting ERROR_INVALID_PARAMETER because the size isn't recognized, because you haven't initialized it. You'll need to allocate memory dynamically because you don't know how big the cache data will be.

Your code probably needs to be something like:
BOOL scan( char* url2search4 )
{
    INTERNET_CACHE_ENTRY_INFO* picei = NULL;
 
    DWORD dwBufferSize = 0;
 
    // Initially using a NULL buffer. This causes FindFirstUrlCacheEntry to tell us
    // how much buffer we need.
 
    HANDLE cacheHandle = FindFirstUrlCacheEntry( NULL, picei, &dwBufferSize );
    BOOL success = FALSE;
 
    // The 'first' entry could have changed between our first call and now, and
    // the new first entry might have a bigger size, so we loop until it tells us
    // we have enough buffer.
 
    while ( cacheHandle == NULL && GetLastError() == ERROR_INSUFFICIENT_BUFFER )
    {
        delete[] (TCHAR*) picei;
        picei = (INTERNET_CACHE_ENTRY_INFO*) new TCHAR[dwBufferSize];
 
        // Important: tell the API which version of the structure to use.
 
        picei->dwStructSize = sizeof( INTERNET_CACHE_ENTRY_INFO );
 
        cacheHandle = FindFirstUrlCacheEntry( NULL, picei, &dwBufferSize );
    }
 
    if ( cacheHandle != NULL )
    {
        // For FindFirstFile/FindNextFile I use a do/while
        // loop but this has buffer complications. Loop
        // forever until a break statement is reached.
        // Conceptually it's a do/while loop.

        for( ; ; )
        {
            // Handle this entry
 
            // I'm just going to write the URL to the console
            puts( picei->lpszSourceUrlName );
 
            // Read next entry
            // Complicated by the fact that we might need a bigger buffer, therefore
            // the function might return FALSE even if there's more data - so we need
            // to see why it failed, and allocate more buffer if required.
 
            success = FindNextUrlCacheEntry( cacheHandle, picei, &dwBufferSize );
 
            while ( !success && GetLastError() == ERROR_INSUFFICIENT_BUFFER )
            {
                picei = (INTERNET_CACHE_ENTRY_INFO*) new TCHAR[dwBufferSize];
                picei->dwStructSize = sizeof( INTERNET_CACHE_ENTRY_INFO );
 
                success = FindNextUrlCacheEntry( cacheHandle, picei, &dwBufferSize );
            }
 
            // If success is still FALSE, there's no more data or some other error
 
            if ( !success )
                break;
        }
 
        FindCloseUrlCache( cacheHandle );
    }
 
    delete[] (TCHAR*) picei;
 
    return TRUE;
}
Hope this helps.

Stability. What an interesting concept. -- Chris Maunder
GeneralRe: FindFirstUrlCacheEntry problem Pin
Spiritofamerica18-Mar-05 10:18
Spiritofamerica18-Mar-05 10:18 
GeneralRe: FindFirstUrlCacheEntry problem Pin
Spiritofamerica9-May-05 12:26
Spiritofamerica9-May-05 12:26 
Questionhow to post a custom message in mfc Pin
Anonymous17-Mar-05 22:41
Anonymous17-Mar-05 22:41 
AnswerRe: how to post a custom message in mfc Pin
bouli18-Mar-05 1:59
bouli18-Mar-05 1:59 
GeneralRe: how to post a custom message in mfc Pin
Ravi Bhavnani18-Mar-05 3:05
professionalRavi Bhavnani18-Mar-05 3:05 
GeneralRe: how to post a custom message in mfc Pin
John R. Shaw18-Mar-05 7:44
John R. Shaw18-Mar-05 7:44 
GeneralRe: how to post a custom message in mfc Pin
Blake Miller18-Mar-05 11:50
Blake Miller18-Mar-05 11:50 
QuestionHow to make a button invisible dynamically Pin
caykahve17-Mar-05 22:25
caykahve17-Mar-05 22:25 
AnswerRe: How to make a button invisible dynamically Pin
Mike Dimmick17-Mar-05 22:33
Mike Dimmick17-Mar-05 22:33 
GeneralRe: How to make a button invisible dynamically Pin
caykahve17-Mar-05 22:58
caykahve17-Mar-05 22:58 
GeneralRe: How to make a button invisible dynamically Pin
Cedric Moonen18-Mar-05 1:04
Cedric Moonen18-Mar-05 1:04 
GeneralRe: How to make a button invisible dynamically Pin
Blake Miller18-Mar-05 11:52
Blake Miller18-Mar-05 11:52 
General#define problem Pin
cmk17-Mar-05 22:19
cmk17-Mar-05 22:19 
GeneralRe: #define problem Pin
Bob Stanneveld18-Mar-05 0:39
Bob Stanneveld18-Mar-05 0:39 
GeneralRe: #define problem Pin
cmk18-Mar-05 11:57
cmk18-Mar-05 11:57 
QuestionHow to find from where do Outlookaddin get the resource ? Pin
xcavin17-Mar-05 22:10
xcavin17-Mar-05 22:10 
QuestionHow can i use ..........in windows 98? Pin
deldeep17-Mar-05 20:02
deldeep17-Mar-05 20:02 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.