4

Attempting to disable BSTR caching:

SetOaNoCache();

VC++ compiler build output:

  • 'SetOaNoCache': identifier not found

Don't want to use:

  • OANOCACHE=1

Question:

Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
Aaron
  • 2,823
  • 9
  • 44
  • 57

2 Answers2

8

It is not defined in a header file, it is in OLEAUT32.dll. You can call it like this:

typedef int (*SETOANOCACHE)(void);

void DisableBSTRCache() { HINSTANCE hLib = LoadLibrary("OLEAUT32.DLL"); if (hLib != NULL) { SETOANOCACHE SetOaNoCache = (SETOANOCACHE)GetProcAddress(hLib, "SetOaNoCache"); if (SetOaNoCache != NULL) SetOaNoCache(); FreeLibrary(hLib); } }

Patrick Glandien
  • 7,791
  • 5
  • 41
  • 47
  • +1: @sikx - thanks dude! I'll try it out :). Where can I find out more about this? How did you know it was in OLEAUT32.dll? – Aaron Feb 16 '09 at 16:29
  • 2
    2 minutes with google: http://www.tech-archive.net/Archive/VC/microsoft.public.vc.atl/2005-03/0184.html – Patrick Glandien Feb 16 '09 at 16:30
  • Should be declared as "void __cdecl SetOaNoCache(void)". See MSDN article: https://msdn.microsoft.com/en-us/library/windows/desktop/ms644360(v=vs.85).aspx – Giorgi Chakhidze Apr 28 '15 at 15:53
3

It's not. From the Win32 API library shipped with C++ Builder:

Requirements

Windows XP: Requires Windows XP Service Pack 2 or later.

Windows 95/98: Not supported.

Header: Not supplied. Declare prototype as shown.

Library: Use oleaut32.lib.

The prototype as shown:

inline void TurnOffCache ()
{
// Function prototype.
extern "C" SetOaNoCache(); 
// Turn off BSTR caching.
SetOaNoCache();
}
Ken White
  • 123,280
  • 14
  • 225
  • 444