<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<title><![CDATA[Серый форум &mdash; VBScript: регистрация COM-библиотек с помощью dynwrap.dll и Win32API]]></title>
		<link>https://forum.script-coding.com/viewtopic.php?id=458</link>
		<atom:link href="https://forum.script-coding.com/extern.php?action=feed&amp;tid=458&amp;type=rss" rel="self" type="application/rss+xml" />
		<description><![CDATA[Недавние сообщения в теме «VBScript: регистрация COM-библиотек с помощью dynwrap.dll и Win32API».]]></description>
		<lastBuildDate>Wed, 09 May 2007 08:51:43 +0000</lastBuildDate>
		<generator>PunBB</generator>
		<item>
			<title><![CDATA[VBScript: регистрация COM-библиотек с помощью dynwrap.dll и Win32API]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=2805#p2805</link>
			<description><![CDATA[<p>Автор скрипта - <strong>Poltergeyst</strong>.<br />Альтернатива утилите regsvr32.exe, работает в OC Win98/Me и WinXP. Потребуется библиотека <a href="http://www.script-coding.com/dynwrap.html">dynwrap.dll</a>.<br /></p><div class="codebox"><pre><code>&#039;Нет гарантий!Используете на свой страх и риск.
&#039;--------------------------------------------------------------------------------------------
&#039;Этот скрипт предназначен для регистрации поставщиков ActiveX
&#039;в реестре и является альтернативным аналогом утилиты regsvr32.exe
&#039;--------------------------------------------------------------------------------------------
&#039;Требуется предварительно зарегистрированная библиотека dynwrap.dll
&#039;OC Win98/Me
&#039;--------------------------------------------------------------------------------------------
&#039;Чтобы эффективно задействовать этот код и встроить контекстную
&#039;команду для Dll файлов в меню проводника,добавьте в реестр 
&#039;следующие данные(формат reg файла):
&#039;
&#039;    [HKEY_CLASSES_ROOT\.dll]
&#039;    @=&quot;dllfile&quot;

&#039;    [HKEY_CLASSES_ROOT\dllfile\shell]
&#039;    [HKEY_CLASSES_ROOT\dllfile\shell\Регистрировать DLL]
&#039;    [HKEY_CLASSES_ROOT\dllfile\shell\Регистрировать DLL\command]
&#039;    @=&quot;Wscript.exe C:\\...\\regSvr.vbs \&quot;%1\&quot; r&quot;

&#039;    [HKEY_CLASSES_ROOT\dllfile\shell\Отменить регистрацию DLL]
&#039;    [HKEY_CLASSES_ROOT\dllfile\shell\Отменить регистрацию DLL\command]
&#039;    @=&quot;Wscript.exe C:\\...\\regSvr.vbs \&quot;%1\&quot; u&quot;

&#039;а для конкретного случая просто создайте ярлык вида:
&#039;    regSvr.vbs &quot;путь к DLL или OCX файлу&quot; &lt;параметр&gt;
&#039;где &lt;параметр&gt;-r для регистрации,u для отмены регистрации DLL.

&#039;То же самое должно работать и для OCX файлов.
&#039;--------------------------------------------------------------------------------------------
&#039;--------------------------------------------------------------------------------------------
if WScript.Arguments.Count=0 then WScript.Quit(-1)

fileName=WScript.Arguments(0)
param    =WScript.Arguments(1)

    if param=&quot;r&quot; then entry=&quot;DllRegisterServer&quot;
    if param=&quot;u&quot; then entry=&quot;DllUnregisterServer&quot;
    
    registerActiveX(fileName)

&#039;--------------------------------------------------------------------------------------------
&#039;[Регистрация сервера ActiveX]

function registerActiveX(fObj)
&#039;-----------------------------------------------
&#039;[Инициация библиотеки в память]
    
set dllWrap=CreateObject(&quot;DynamicWrapper&quot;)
    
&#039;Регистрация вызова API
dllWrap.Register _
    &quot;kernel32.DLL&quot;, _
    &quot;LoadLibraryA&quot;, _
    &quot;i=s&quot;, _
    &quot;f=s&quot;, _
    &quot;r=l&quot;
&#039;-----------------------------------------------
&#039;Вызов API
    hLib=dllWrap.LoadLibraryA(Cstr(fObj))
    set dllWrap=Nothing
&#039;-----------------------------------------------
if hLib=0 then 
    MsgBox &quot;Невозможно загрузить библиотеку &quot; &amp; fObj, _
    vbExclamation, _
    &quot;Ошибка регистрации&quot;
    WScript.Quit(-1)
end If
&#039;-----------------------------------------------
&#039;-----------------------------------------------
&#039;[Проверка точки входа]

set dllWrap=CreateObject(&quot;DynamicWrapper&quot;)

&#039;Регистрация вызова API
dllWrap.Register _
    &quot;kernel32.DLL&quot;, _
    &quot;GetProcAddress&quot;, _
    &quot;i=ls&quot;, _
    &quot;f=s&quot;, _
    &quot;r=l&quot;
&#039;-----------------------------------------------
&#039;Вызов API
    pAdr=dllWrap.GetProcAddress(hLib,Cstr(entry))
    set dllWrap=Nothing
&#039;-----------------------------------------------
if pAdr=0 then 
    MsgBox &quot;Отсутствует точка входа &quot; &amp; entry &amp; _
        &quot;.Возможно этот файл не является поставщиком ActiveX.&quot;, _
        vbExclamation, _
        &quot;Ошибка регистрации&quot;

        freeLibrary(hLib)    &#039;Освобождение дескриптора
        WScript.Quit(-1)
end If
&#039;------------------------------------------------    
&#039;-----------------------------------------------
&#039;[Регистрация поставщика ActiveX]

set dllWrap=CreateObject(&quot;DynamicWrapper&quot;)
        
&#039;Регистрация вызова API
dllWrap.Register _
    Cstr(fObj), _
    Cstr(entry), _
    &quot;f=s&quot;, _
    &quot;r=l&quot;    
&#039;-----------------------------------------------
&#039;Вызов API
    if param=&quot;r&quot; then reg=dllWrap.DllRegisterServer()    
    if param=&quot;u&quot; then reg=dllWrap.DllUnregisterServer()    
    set dllWrap=Nothing
&#039;-----------------------------------------------
if reg&lt;&gt;0 then 
    MsgBox &quot;Ошибка работы &quot; &amp; entry, _
        vbExclamation, _
        &quot;Ошибка регистрации&quot;

        freeLibrary(hLib)    &#039;Освобождение дескриптора
        WScript.Quit(-1)
end If            
&#039;-----------------------------------------------
&#039;-----------------------------------------------
freeLibrary(hLib)    &#039;Освобождение дескриптора        

&#039;Контрольные сообщения
&#039;-----------------------------------------------
if param=&quot;r&quot; then
    MsgBox &quot;Файл &quot; &amp; fObj &amp; &quot; является поставщиком ActiveX и зарегистрирован в реестре.&quot;, _
        vbInformation, _
        &quot;Успешная регистрация&quot;
end If
&#039;-----------------------------------------------
if param=&quot;u&quot; then
    MsgBox &quot;Файл &quot; &amp; fObj &amp; &quot; является поставщиком ActiveX.Регистрация отменена.&quot;, _
        vbInformation, _
        &quot;Успешная отмена регистрации&quot;
end If
&#039;-----------------------------------------------    

end Function


&#039;--------------------------------------------------------------------------------------------
&#039;[Освобождение дескриптора библиотеки (вспомогательная функция)]
function freeLibrary(hLib)
    &#039;-------------------------------------------------------
    &#039;[Освобождение дескриптора]        
                
    set dllWrap=CreateObject(&quot;DynamicWrapper&quot;)
            
    &#039;Регистрация вызова API
    dllWrap.Register _
    &quot;kernel32.DLL&quot;, _
    &quot;FreeLibrary&quot;, _
    &quot;i=l&quot;, _
    &quot;f=s&quot;
        
    &#039;Вызов API
    dllWrap.FreeLibrary(hLib)    
    set dllWrap=Nothing

    hLib=Null

end Function
&#039;--------------------------------------------------------------------------------------------
&#039;--------------------------------------------------------------------------------------------</code></pre></div>]]></description>
			<author><![CDATA[null@example.com (The gray Cardinal)]]></author>
			<pubDate>Wed, 09 May 2007 08:51:43 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=2805#p2805</guid>
		</item>
	</channel>
</rss>
