Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

SxS DLL location

25 views
Skip to first unread message

Kevin Provance

unread,
Dec 3, 2007, 7:15:09 PM12/3/07
to
Is there some convenient way to determine the location of a SxS installed
DLL (in this case, msvcr80.dll). Since it can no longer be installed in the
app folder or the system folder, it must be installed as a SxS via a redist
program. All I need to do now is to determine where on the hard drive it's
installed, as there is a plethora of entries in the SxS folder. I peeked in
the registry, but I need CLSIDs and whatnot to base my search on. Google
isn't being much help either (anyone remember when Google was actually
useful?)

- Kev


Steve Easton

unread,
Dec 4, 2007, 11:51:30 AM12/4/07
to
It lives here:
C:\WINDOWS\WinSxS\x86_Microsoft.VC80.CRT_1fc8b3b9a1e18e3b_8.0.50727.762_x-ww_6b128700
and here:
C:\WINDOWS\WinSxS\x86_Microsoft.VC80.CRT_1fc8b3b9a1e18e3b_8.0.50727.163_x-ww_681e29fb
and here:
C:\WINDOWS\WinSxS\x86_Microsoft.VC80.CRT_1fc8b3b9a1e18e3b_8.0.50727.42_x-ww_0de06acd
each a different version.

There's a registry entry here:
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\SideBySide\PatchedComponents
which shows this CLSID for all of the versions:
{9B2AF11A-A6B3-11EE-B01F-C8B3B9A1E18E}

However neither the dll or the CLSID are registered anywhere else in the registry,
such as HKCR

hth

--

Steve Easton


"Kevin Provance" <ca...@tpasoft.com> wrote in message news:%23c6n6qg...@TK2MSFTNGP03.phx.gbl...

Kevin Provance

unread,
Dec 4, 2007, 3:51:37 PM12/4/07
to
Thanks for the effort Steve.

I came up with a different workaround using the PSAPI.dll. I was able to
enumerate the module handles from the process handle of my own program
(since it loads the dll in question), then using GetModuleFileNameEx I
obtained the path of the loaded dll.

If anyone wants me to post the code, I'd be happy to.

- Kev

"Steve Easton" <ad...@95isalive.com> wrote in message
news:OnbMJYpN...@TK2MSFTNGP06.phx.gbl...

Kevin Provance

unread,
Dec 4, 2007, 7:28:25 PM12/4/07
to
Here is the code for my workaround, should anyone want it.

Option Explicit

Private Declare Function OpenProcess Lib "kernel32" (ByVal dwDesiredAccess
As Long, _
ByVal bInheritHandle As Long, ByVal dwProcessId As Long) As Long

Private Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Long)
As Long

Private Declare Function EnumProcesses Lib "PSAPI.DLL" (lpidProcess As Long,
_
ByVal cb As Long, cbNeeded As Long) As Long

Private Declare Function EnumProcessModules Lib "PSAPI.DLL" (ByVal hProcess
As Long, _
lphModule As Long, ByVal cb As Long, lpcbNeeded As Long) As Long

Private Declare Function GetModuleBaseName Lib "PSAPI.DLL" Alias _
"GetModuleBaseNameA" (ByVal hProcess As Long, ByVal hModule As Long, _
ByVal lpFileName As String, ByVal nSize As Long) As Long

Private Declare Function GetModuleFileNameEx Lib "PSAPI.DLL" _
Alias "GetModuleFileNameExA" (ByVal hProcess As Long, ByVal hModule As Long,
_
ByVal lpFileName As String, ByVal nSize As Long) As Long

Private Const PROCESS_VM_READ As Long = &H10
Private Const PROCESS_QUERY_INFORMATION As Long = &H400

Public Function GetDllPathFromProcess(ByVal sDll As String, ByVal sProcess
As String) As String

'sDll is the name of the DLL you want the path to
'sProcess is the name of the program that loads the DLL. Typically this
will be your own EXE

Dim lProcesses() As Long
Dim cbNeeded As Long
Dim cProcesses As Long
Dim lProcessCount As Long
Dim lCount As Long
Dim lProcessID As Long
Dim lLen As Long
Dim hProcess As Long
Dim hMod(0 To 1023) As Long
Dim lR As Long
Dim lMax As Long
Dim sProcessName As String
Dim sDllPath As String

ReDim lProcesses(0 To 1023) As Long

sDllPath = vbNullString

sDll = LCase$(sDll)
sProcess = LCase$(sProcess)

If (EnumProcesses(lProcesses(0), 1024 * 4, cbNeeded) <> 0) Then
cProcesses = cbNeeded / 4

For lProcessCount = 0 To cProcesses - 1
If sDllPath <> vbNullString Then
Exit For
End If

lProcessID = lProcesses(lProcessCount)

lLen = 260

hProcess = OpenProcess(PROCESS_QUERY_INFORMATION _
Or PROCESS_VM_READ, 0, lProcessID)

If lProcessID > 0 Then 'System = 2
If (hProcess <> 0) Then
If (EnumProcessModules(hProcess, hMod(0), 1024 * 4,
cbNeeded)) Then
'itmX.SubItems(4) = cbNeeded \ 4

sProcessName = String$(lLen, 0)
lR = GetModuleBaseName(hProcess, hMod(0), sProcessName,
lLen)
sProcessName = LCase$(Mid$(sProcessName, 1, lR))

If sProcessName = sProcess Then
lMax = cbNeeded \ 4

For lCount = 1 To lMax - 1
sProcessName = String$(lLen, 0)
lR = GetModuleBaseName(hProcess, hMod(lCount),
sProcessName, lLen)
sProcessName = LCase$(Mid$(sProcessName, 1, lR))

If sProcessName = sDll Then
sProcessName = String$(lLen, 0)
lR = GetModuleFileNameEx(hProcess,
hMod(lCount), sProcessName, lLen)
sProcessName = Mid$(sProcessName, 1, lR)
sDllPath = sProcessName
Exit For
End If 'sProcessName = sDll
Next 'lCount
End If 'sProcessName = sProcess
End If 'EnumProcessModules
End If 'hProcess <> 0
End If 'lProcessID = 0
CloseHandle hProcess
Next 'i
End If 'EnumProcesses<>0

GetDllPathFromProcess = sDllPath

End Function

0 new messages