Volleynerd Knowledge Base

Friday, October 31, 2003


VC always wants to build a project

3 reasons why the IDE might think your project is out of date:

326946 - BUG: Issues That Cause a Solution to Rebuild Although Dependencies Are Unchanged



Outbound parameter from event interface

Want to change parameter in the event handler, and have the caller see the change

Just what we figured out last round for SFP. Script event handlers can not modify a standard ( [in,out] SomeType* val ) parameter.

More info now that I've figured this all out

This article tells that you should make the param type [in,out] VARIANT*, but that actually does not work for JavaScript event handlers (e.g. in a web page). Some people imply that VBScript can handle in,out, but I can't get that to work.

HOWTO: Obtain data from the client via an outgoing event dispinterface in ATL

So...when dealing with JavaScript, change the param type to [out,retval] and then the Fire_xxx code should be looking at the varResult (from ATL generated code) instead of the params passed into the Invoke call.


(find this at groups.google.com with search "out retval parameter event group:microsoft.public.vc.*" )

Update: more info here about using this event from JScript.

Apparently JScript doesn't do [in,out] params, so you have to go with the [out,retval] attributes, and pull the return value out of the 6th param in Invoke.

ATL Wizard code generates mostly correct code (currently using VS 7.1), with zero params (out,retval is not sent in as a param)....but the return value shows up from the 6th param in Invoke. You have to pull this value out of the CComVariant and return it from the Fire_xxx function.

IDL function declaration:

[id(2)] HRESULT OutRetvalVar([out,retval] VARIANT* val);

HRESULT Fire_OutRetvalVar( VARIANT *  val) {


...

CComVariant avarParams[1];
avarParams[0].pvarVal = val;
avarParams[0].vt = VT_BYREF | VT_VARIANT;
CComVariant varResult;
DISPPARAMS params = { avarParams, NULL, 1, 0 };
// go ahead and pass params here, but JScript will ignore
hr = pConnection->Invoke(2, IID_NULL, LOCALE_USER_DEFAULT,
DISPATCH_METHOD, &params, &varResult, NULL, NULL);
// return value from event handler will be in varResult
::VariantCopy( val, &varResult );

...
}


JScript event handling code looks like this (notice the lack of parameter in the event handler function signature):
<script language="javascript" for="dan" event="OutRetvalVar">

alert( 'got OutRetvalVar (jscript), return true' );
return true;
</script>





Saturday, October 25, 2003


Thursday, October 23, 2003


CodeProject articles

Jeff @ work found some good articles here.

Put @ERR,hr (shows GetLastError value, as HRESULT) and @EAX,hr (shows return value from last function call) in a watch window.

The Code Project - Free Source Code and Tutorials

(also in this author's list of articles is "idot's guide to writing shell extensions, COM tutorial, C++ class to wrap the Windows scheduler, WTL tutorials)



Hiberfil.sys large file on XP

This file is sitting on the root of the system drive on XP machines. It's rather large, so was wondering what it was.

Turns out it's the file where the RAM state is flushed when the machine goes into hibernate mode. (Apparently on by default in XP, even for desktops! )

Turn this off in Control Panel, Power Options, Hibernate, Enable Hibernation.
Poof !! The file is gone.

Thanks to this post for the info on this one.




STA COM exe server receives inbound calls on random thread

At work today, Tim's COM exe server was recieving inbound calls from client calls on random RPC threads, even though his EXE was calling CoInitialize(0) in WinMain, therefore putting the object into the STA.

Turns out, the object was originally created with the Add New Class wizard, and the box was checked for "Free Threaded Marshaller".

What this does apparently is the proxy/stub code sends the client request into the EXE on one of it's COM/RPC provided threads.

The Free Threaded Marshaller is created in an ATL object's implementation of FinalConstruct. There you will see the call to CoCreateFreeThreadedMarshaler



Friday, October 17, 2003


Oracle SQLPlus Help


help on commands in oracle sql plus SQLPlus commands




Wednesday, October 15, 2003


Hard Drive Activity during Idle time on XP Laptop

Work laptop, after idle for a while, starts churning the disk until I come back and wake it up.

Based on google groups searches, seems to be one of following:
  • Indexing service for that drive (turn this off in properties for the drive)
  • System Restore cab'ing up files for a restore point (can only turn off all of system restore).
  • Optimizations XP makes, moving files to faster sections of the drive (don't know how to turn this off)


But....why doesn't this happen on my desktop? (It has indexing turned on, and System Restore enabled)

The saga continues....

Ok, found the problem (I think).

Set Local security policy to track process starts/stops. Found that defrag.exe and dfrgntfs.exe would run during the idle / screen saver time.

Found info about it on this Windows XP A to Z page, they talk about the prefetch mechanism that moves files around on disk to make XP boot/run faster.

In case the page is gone someday, the info to disable:
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Memory Management\PrefetchParameters
EnablePrefetcher
0 = disabled
1 = Application launch prefetching
2 = Boot prefetching
3 = both

temp files and organization are done in <windir>\PreFetch.
Look at layout.ini where the optimal storage layout is described.


keywords: hard drive hd spin constantly activity idle xp laptop



Tuesday, October 07, 2003


Changes in IE due to Legal Ruling

Apparently, IE's default handling of ActiveX controls will change -- here's more info:

Information for Developers about Changes to Internet Explorer



Sunday, October 05, 2003


Cool Google "Searches"

From ComputorEdge, Sept 26, 2003, cool ways to search at google

(many of these can be done in the advanced search page at google )

intext -- Find only pages that have search term in the text (not in title, URLs, tags, etc)
intext: ex: "Gretchen" intext:www.computoredge.com
(btw, can use this with the site argument to bypass some password-protected sites!?)

inurl -- Look for the URL references in all indexed pages.
site: ex: "Digital Dave" inurl:www.computoredge.com

site -- Restrict search to a given URL or top level domain.
site: ex: "digital dave" site:edu

daterange -- based on julian date, use Julian Date Converter

link -- Find sites that link to the given url
link: ex: link:www.computoredge.com

phonebook -- lookup residential and commercial phone numbers
phonebook: or
ex: phonebook:William Smith CA
ex: phonebook:(903)555-3454

(see google "services / features" pages for more info on white/yellow pages lookups)

calculator -- does any mathematical calculations, and even conversions.
"half cup in teaspoons" "10 kilometers in miles" etc.



Show Hidden Items in Add/Remove Programs (Windows Components)

The Screen Savers tip. Open sysoc.inf in windows\inf directory. In the "components" section, look for the entries with "hide" parameter towards end of the line. Remove "hide" (leave empty slot with two commas).

Close and reload the windows components list and you should see the new item(s).

keywords: add remove programs hidden show hide



Friday, October 03, 2003


Thursday, October 02, 2003


Disable Right Click in Browser

Thanks to Charles for showing me the light.
<script>


isNN = document.layers ? 1 : 0;

function noContext(){return false;}

function noContextKey(e) {
if(isNN){
if (e.keyCode == 96){ return (false);}
} else {
if (event.keyCode == 96){ return (false);}
}
}

function noClick(e){
if(isNN){
if(e.which > 1) {return false;}
} else {
if(event.button > 1){return false;}
}
}

if(isNN){
document.captureEvents(Event.MOUSEDOWN);
}

document.oncontextmenu = noContext;
document.onkeypress = noContextKey;
document.onmousedown = noClick;
document.onmouseup = noClick;

</script>




Wednesday, October 01, 2003


VC 7.x COM component categories unregistration

Since moving up to VC 7.x (.NET 2003), we've been getting access denied when unregistering a com component that has safe for scripting registry entries (in the .RGS file).

I haven't fully followed all the code down through statreg.h (line 1379 is key delete) but seems that only ONE of the component categories keys was being deleted....then when trying to delete the parent key, it would fail (0x80070005 -- acess denied).

Fix for now seems to be -- add ForceRemove before the category, then before each of the listed categories.
ForceRemove 'Implemented Categories'

{
ForceRemove {7DD95801-9882-11CF-9FA9-00AA006C42C4} =
s 'Controls that are safely scriptable'
ForceRemove {7DD95802-9882-11CF-9FA9-00AA006C42C4} =
s 'Controls safely initializable from persistent data'
}


keywords: com component safe for scripting implemented categories RGS ATL



Script can't use [out] variable from COM object?

This is ridiculous!? I can't get a simple COM object to properly pass back an OUT BSTR parameter to a script caller (from IE).

Tried VARIANT* as the param too, but must be missing something.

This is from google groups search, but couldn't get this working either.

------
Ah, if you want VBScript, it has to be [in, out] VARIANT*. On entry
this VARIANT contains VT_BYREF | VT_VARIANT and the referenced
VARIANT contains the value (as VT_I4 for example, but it can also
be in VT_I2 or something else like VT_BSTR). You have to interpret
the value no matter its format and then store the new value in this same
embedded VARIANT. You shouldn't touch the outer VARIANT.
See VariantChangeType - use it to convert all possible formats into
VT_I4 so you don't have to deal with all possible cases...
------

keywords: script javascript vbscript com object byref by reference outbound parameter



Home