Is any way register shell extension by Regasm.exe without codebase? - contextmenu

this is problem.
I developed a shell extension of Shell Context Menus.
(use SharpShell, enter link description here)
I can register it by using regasm.exe with "/codebase" attribute.
And without this attribute the shell extension doesn't work.
But this attribute let me can't update the .dll file without reboot explorer.
Even worse, can't delete .dll file after that unregistered and reboot PC (in windows 8).
So, did that have any way to solve this problem?
By the way, if anyone can tell me what is "/codebase" actually doing?
(I saw MSDN already, but totally can't understand.)

The only solution is to enumerate the handles created by explorer.exe and filter them by the target file, which is your own locked dll file. Then you can remove the handle.
It would require P/invoke if you will use C#, or handle.exe by Sysinternals if you will use any scripting language during installation. However, removing handles in the background of the application that has the handle is an unsupported way and may result with undefined consequences.

Related

Delphi copy files to systemdir problem in Windows 7

i can use the copyfile(); function to copy a file to c:/windows/system32 on windows xp but then i use the function on windows 7 i cant copy it:o the file wont come there....
i had the same problem with writing and reading registery but fixed it by declaring a WOW key $0100 ...
i think the problem is uac but not sure.. could somebody explain me that:D?
That is indeed because of UAC. It is called File/Folder or Registry Virtualization. It is done for legacy applications who don't yet respect the new UAC rules (e.g. not writing in system folders unless you are an administrator).
By creating a manifest file you switch off this virtualization. See here. This can be a seperate file or be embedded into the exe. Newer Delphi versions already generate executables containing such a manifest and have requestedExecutionLevel set to asInvoker. This normally does not allow writing in those locations, unless users specifically run your program as an administrator. Setting it to requireAdministrator does allow writing in those locations, but also means users have to confirm they want to run your program as an administrator.
It's indeed UAC that's preventing you from copying files to the system32 folder. You have to ask yourself why you want to copy files there. A normal application should never copy files to the system32 folder.
Sometimes during install you might want to copy dll's there, but even that is legacy behaviour. Should you really want to copy files there, you should request Elevation at the start of the application.
Why are you copying files there? It should be treatead as the OS private directory. Unless you're installing a driver or the like, you should never write there. In XP you can only because you're running with Administrator privileges, try to use a plain user and you can't as well (since at least 2000, if not in NT already), but it will give you an error because it won't redirect the write. Unless you have a truly good reason to write there, I'd suggest to redesign your application to write in the proper place, instead of trying to find a way to write there. Anyway, it will fail anytime the user don't have the privileges and can't perform an elevation.

Why does my program say "folder does not exist" when run on Windows 2008?

We have a Delphi program whose task is like a service program. It watches a particular folder for a certain period, and it works great on Windows XP and 2003, but on Windows 2008r2 64bit, when it wants to create an automatic folder, it will show this message:
The ... folder does not exist. The file may have been moved or deleted.
This message causes the program to halt, which is not good; it should not be interrupted.
What can I do about this?
P.S.: I really don't have any idea whether to post my problem in Stack Overflow or Server Fault, so I've guessed it should be here.
It's likely the VirtualStore, if you're trying to store beneath Program Files (either one). See my writeup:
http://www.clipboardextender.com/off-topic/vista-program-files-hide-and-seek
You've left out the ... folder name. While that's understandable, it wouldn't happen to have anything to do with program files (which on x64 will be split in 2 directories) would it?
Windows Server 2008 is able to use 'virtual' file pathes. That means: 'what you see is not what you get'. The Windows Explorer just shows you the 'display' name. Check the file path with cmd.exe, if the path you are trying to use does realy exist.
The reason is of cause the File Virtualization (see for example http://msdn.microsoft.com/en-us/library/bb756960.aspx and http://technet.microsoft.com/en-us/magazine/2007.06.uac.aspx).
Because we on stackoverflow.com and not on serverfault.com I want add to all other answers that you can use Wow64DisableWow64FsRedirection, Wow64RevertWow64FsRedirection and Wow64EnableWow64FsRedirection functions (see http://msdn.microsoft.com/en-us/library/aa365743.aspx) to control the File Virtualization in your program. An example of the usage of this functions in C# you can find here http://www.pinvoke.net/default.aspx/kernel32.wow64disablewow64fsredirection.
You'll need to tell us the exact path and how do you go about constructing it. It can be as simple as the app not using env variable expansion but assuming that user's folders are where they were before.
Path virtualization (there are 2 kids actually) that people mentioned will hit you only if your app is trying to mess with system folders.
More puzzling problem will hit you if you are not expanding env vars like APPDATA, LOCALAPPDATA etc. and not expecting that there's more of them on Win7 and 2k8. Not only that default paths of user's files changed but some of them can also be on network shares - for the same user. So if you were running based on expectation that all user's stuff will be at definite paths under say %USERPROFILE% you can get hit by several surprises. Also notice %ProgramData% .
Fastest way to find out - open cmd.exe, run set and if you see some paths that you are constructing in alternative ways, take notice that you need to start expanding env vars for them. Then open cmd.exe as a 32-bit app and check set again. You can also pick them up via Process Explorer from some running 32-bit or 64-bit app.
Switching your app to 64-bit build will resolve most of virtualization issues but not the env var expansion. Also if your app is touching system folders you need to request elevated run from the code or even better make the manifest and declare it there. Then OS will yell at user up front if his UAC is on and your app will avoid that 2nd virtualization. BTW, virtualization is controllable via group policies so it might be present on some boxes and missing on others.

Updating UMDF drivers during development

I am having some trouble updating UMDF drivers using "devcon" during a
standard code-deploy-debug cycle. The problem is that "devcon update" isn't
really updating anything unless the version number or the date of the DLL
file and the INF file has changed from what is stored in the system's driver
cache folder. After a maddening series of experiments I've discovered that
one way to force the thing to use the latest files is by doing the
following:
Change the parameters passed to
"stampinf.exe" in "makefile.inc" by
explicitly setting a version with
the "-v" option.
Modify the
resource script file ("DRIVER_NAME.rc") to first define
VER_USE_OTHER_MAJOR_MINOR_VER
before including "ntverp.h" and then
explicitly define
VER_PRODUCTMAJORVERSION and
VER_PRODUCTMINORVERSION. You'll
note that this system does not allow
us to change the build and the
revision numbers. On Win7 this
seems to be fixed at 7600 and 16385
in "ntverp.h". Is this by design?
So, I first modify "makefile.inc" and set the "-v" option to something like
"1.1.7600.16385" manually incrementing the minor version for every single
build and then modify the RC file and update VER_PRODUCTMINORVERSION with
the same number.
Alternatively, if I run a command prompt under the SYSTEM account and go and
delete the driver cache folder in
"C:\windows\system32\DriverStore\FileRepository\DRIVER FOLDER" before
running "devcon" then that works too.
Now, I am thinking I am missing something fairly basic here as this seems to
be a rather painful way of doing it. Please help! Thanks!
Why can't you just unplug the device and replace the unloaded DLL? You shouldn't need to reinstall the driver, just replace the module. Note that you shouldn't do this during production or anything that has to do with customers, but if you're writing a driver, just slam in the new module with the same version number.
On Win7 this seems to be fixed at 7600 and 16385 in "ntverp.h". Is this by design?
Yep, at least until the next service pack
As Paul Betts has suggested above, the way to go seems to be to simply replace the UMDF DLL directly in the driver folder (for e.g. c:\windows\system32\drivers\umdf\) after disabling the device either in the device manager or using "devcon". I'd asked this question on Microsoft's device drivers newsgroup before posting here but hadn't got a satisfactory response - but some folks ended up responding there after I posted here! So I'll put up a link to that post as well:
http://bit.ly/6PDxKT

Windows Explorer Context menu opening already running Delphi app

If I right click on several files and choose windows context menu, how to send the selected name of files to my program. My program has already running and I dont want my program to be executed again because my program use mutex and uac.
I am using delphi, if you have clues, reference or sample code, really appreciate.
Besides using launcher app like Ignacio suggests you could use DDE to contact already running applications. Another option is writing your own shell extension. You can read more about it here.
Use a helper app that starts the program if necessary, then sends the filenames to be processed via a mailslot.

Delphi app calling cobol app -> error

We need to get data out of an older accounting system. We have received a dll that gives us access to the data we need. It includes a type library that we have imported.
If we run our test application from the same directory as the accounting system, everything works fine. If we try to run our application from a different directory, we get the following error:
Dynamically Bound RTS
Runtime DLL 'OOPS', version 3.1, entry point oops
not recorded in registry, not found or incompatible with requirements
of dynamically bound COBOL program. Dynamic binding of RTS requires:
Runtime DLL 'OOLSM', at least Version 3.1
Can anybody provide some helpful information on this?
Are we supposed to have some kind of cobol runtime in our directory? Or in the path? Or registered in the registry?
Thanks,
-Vegar
Updates:
Setting the system %path% to include the path to the accounting system seems to do the trick. Including it as a user variable did not have the same effect for some reason.
What Cobol are you using?
I had done this for year with Microfocus NetExpress 3.1, and all works just fine.
I write COBOL DLL to access COBOL data files, and also write Delphi DLL to add new features to old COBOL systens.
And yes, I use to set the runtime path, that is environment variable called COBDIR, there are others,but usually %PATH% and %COBDIR%is enough.
If you give more detais about what COBOL compiler are you using, and how is the dll interface that you are calling, will me ore easy to help you.
And maybe "Dependence Walker" can help you to identify what run time files are missing, if it is.
http://www.dependencywalker.com/
If it works from the accounting app's directory, but not a different one, the first thing I'd try is adding that directory to your path.
Unless it is already loaded into memory, Windows looks for DLL's that a program is requesting in every location listed in its PATH environment variable, and also in the directory the application is located within.

Resources