ورود

View Full Version : نصب یک DLL



Hadizadeh
چهارشنبه 17 مرداد 1386, 11:19 صبح
سلام. من یک DLL دارم که در حالت عادی در بخش Component>>Import ActiveX Control دیده میشه. بنابراین می تونم اون رو با زدن دکمه Install تو پالت ActiveX دلفی نصب کنم. ولی اگه بخواهیم این فایل رو روی یه کامپیوتری مورد استفاده قرار بدیم چه طور میشه اونو register و یا install کرد؟ من با Regsvr32 mydll.dll تست کردم اما خطا می ده. راهش چیه؟ ممنون

cybercoder
چهارشنبه 17 مرداد 1386, 11:54 صبح
در مورد این مسئله قبلا خیلی بحث شده می تونید فروم رو جستجو کنید.
http://barnamenevis.org/forum/search.php?searchid=515784

Hadizadeh
چهارشنبه 17 مرداد 1386, 12:24 عصر
لینک شما رو کلیک کردم گفت که هیچ موردی پیدا نشد!!

mzjahromi
چهارشنبه 17 مرداد 1386, 12:31 عصر
در مورد این مسئله قبلا خیلی بحث شده می تونید فروم رو جستجو کنید.
http://barnamenevis.org/forum/search.php?searchid=515784

دوست عزیز نتیجه جستجوی متعلق به کامپیوتر شما است و نمی تونید توی انجمن نمیتونید لینکش رو بذارید


سلام. من یک DLL دارم که در حالت عادی در بخش Component>>Import ActiveX Control دیده میشه. بنابراین می تونم اون رو با زدن دکمه Install تو پالت ActiveX دلفی نصب کنم. ولی اگه بخواهیم این فایل رو روی یه کامپیوتری مورد استفاده قرار بدیم چه طور میشه اونو register و یا install کرد؟ من با Regsvr32 mydll.dll تست کردم اما خطا می ده. راهش چیه؟ ممنون

من روشهای مختلفی رو دیدم برای ثبت dll ها
یکی اش RegSvr32 بود که گفتید تست کردید نمیشه
یکیش هم انتخاب بسته مربوطه از توی InstallShield بود

پیشنهاد:
توی Registry یه جستجو بکنید ببینید رد پائی ازش پیدا میکنید؟

Hadizadeh
چهارشنبه 17 مرداد 1386, 12:39 عصر
آره اسمش رو سرچ کردم یه کلید به نام InprocServer32 پیدا کرد که دو تا مقدار که حاوی مسیر فایل dll و همچنین ThreadingModel توش هست. ولی خوب توی یک ریشه فرعی با یک GUID عجیب و غریب هست . البته GUID های مشابه دیگری هم هستند. خوب حالا چی کار کنم؟

Hadizadeh
چهارشنبه 17 مرداد 1386, 12:42 عصر
ببینید وقتی میزنم Regsvr32 mydll.dll یه دیالوگ با این مضمون ظاهر میشه:


LoadLibrary("mydll.dll") failed. The specified module could not be found.

babak869
چهارشنبه 17 مرداد 1386, 13:17 عصر
برای نصب یک کتیوایکس از طریق کدنویسی دلفی میتونید از روش زیر استفاده نمایید


Registering DLL and ActiveX controls from code

How to register (and unregister) OLE controls such as dynamic-link library (DLL) or ActiveX Controls (OCX) files from a Delphi application



One of the features that make Delphi so popular is that when it comes to project deployment, you as a developer (in most cases) only need to send the executable file (exe) of your application.

However, in some situations, for example when you import an ActiveX control into your project, you'll need to make sure that this ActiveX control is registered on your users machines. If the control is not registered there, an EOleSysError exception will be displayed to your user eyes.

RegSvr32.exe
The regsvr32.exe command-line tool registers dll and ActiveX controls on a system. You can manually use the Regsvr32.exe (Windows.Start - Run) to register and unregister OLE controls such as dynamic link library (DLL) or ActiveX Controls (OCX) files that are self-registerable.
When you use Regsvr32.exe, it attempts to load the component and call its DLLSelfRegister function. If this attempt is successful, Regsvr32.exe displays a dialog indicating success.

RegSvr32.exe has the following command-line options:

Regsvr32 [/u] [/s] [/n] [/i[:cmdline]] dllname

/s - Silent; display no message boxes

/u - Unregister server

/i - Call DllInstall passing it an optional [cmdline];

when used with /u calls dll uninstall

/n - do not call DllRegisterServer; this option must

be used with /i

From Delphi code

To call the regsvr32 tool from within Delphi code, you'll need a function that can execute a file and wait for the execution to finish.

This is how the 'RegisterOCX' procedure could look:

procedure RegisterOCX;

type

TRegFunc = function : HResult; stdcall;

var

ARegFunc : TRegFunc;

aHandle : THandle;

ocxPath : string;

begin

try

ocxPath := ExtractFilePath(Application.ExeName) + 'Flash.ocx';

aHandle := LoadLibrary(PChar(ocxPath));

if aHandle <> 0 then

begin

ARegFunc := GetProcAddress(aHandle,'DllRegisterServer');

if Assigned(ARegFunc) then

begin

ExecAndWait('regsvr32','/s ' + ocxPath);

end;

FreeLibrary(aHandle);

end;

except

ShowMessage(Format('Unable to register %s', [ocxPath]));

end;

end;



Note: the ocxPath variable points to the 'Flash.ocx' Macromedia ActiveX control.

To be able to register itself, an ActiveX control needs to implement the DllRegisterServer function. In simple words, this function creates registry entries for all the classes inside the control. We do not need to worry about the DllRegisterServer function we just want to make sure it is there. For the sake of simplicity, we've presumed that the ActiveX control (the *.ocx file) is located in the same folder as where your application is.

The red line in the above code, does the job of calling the regsvr32 tool by passing the "/s" switch along with the full path to the ActiveX control. The function is ExecAndWait.

uses shellapi;

...

function ExecAndWait(const ExecuteFile, ParamString : string): boolean;

var

SEInfo: TShellExecuteInfo;

ExitCode: DWORD;

begin

FillChar(SEInfo, SizeOf(SEInfo), 0);

SEInfo.cbSize := SizeOf(TShellExecuteInfo);

with SEInfo do begin

fMask := SEE_MASK_NOCLOSEPROCESS;

Wnd := Application.Handle;

lpFile := PChar(ExecuteFile);

lpParameters := PChar(ParamString);

nShow := SW_HIDE;

end;

if ShellExecuteEx(@SEInfo) then

begin

repeat

Application.ProcessMessages;

GetExitCodeProcess(SEInfo.hProcess, ExitCode);

until (ExitCode <> STILL_ACTIVE) or Application.Terminated;

Result:=True;

end

else Result:=False;

end;

The above, ExecAndWait, function uses ShellExecuteEx API call to execute a file on a system. If you need more examples of executing any file from Delphi, check the Start from Delphi article.




منبع :
www.Delphi-About.com

موفق باشید

cybercoder
پنج شنبه 18 مرداد 1386, 02:20 صبح
دوست عزیز نتیجه جستجوی متعلق به کامپیوتر شما است و نمی تونید توی انجمن نمیتونید لینکش رو بذارید

ممنون و شرمنده همش تقصیر این IE6 که Tab به Tab نیست آدم اشتباه می کنه صفحات رو
بازم پوزش از دوستان

Valadi
پنج شنبه 18 مرداد 1386, 07:21 صبح
یک راه دیگه هم هست

Winexec(PChar('regsvr32 /s '+'name dll or Active X'),SW_HIDE);

Hadizadeh
پنج شنبه 18 مرداد 1386, 07:37 صبح
اینا همه درست، به هر حال همه همون راهی رو که خودم تست کردم یعنی استفاده از Regsvr32 را دارید پیشنهاد می دید ولی اون اول گفتم که اینجوری کار نمی کنه. به قول یکی از دوستان ممکنه این DLL، دارای Dependency باشه که باید اون رو پیدا کرد و اونها رو هم اول نصب کرد. ولی راه حل دیگه ای دارید؟ ممنون

Hadizadeh
پنج شنبه 18 مرداد 1386, 08:05 صبح
در حقیقت چه جوری می تونیم Dependecy های یک DLL رو پیدا کنیم؟

mzjahromi
پنج شنبه 18 مرداد 1386, 12:11 عصر
مواردی رو من با پیاده سازی آنچه در رجیستری هست(روی کامپیوتر دیگر) حل کردم ولی برای مورد شما چون نمی دونم فایلتون چیه و چه کار میکنه و از کجا اومده؟ نمیشه گفت دقیقا چه کار باید کرد

mehrdad196
سه شنبه 13 آذر 1386, 11:03 صبح
از این دستور استفاده کن

Tregsvr YOURCLASS.dll

Hadizadeh
سه شنبه 13 آذر 1386, 11:12 صبح
از این دستور استفاده کن

Tregsvr YOURCLASS.dll

نه این دستور که اونو رجیستر می کنه، وابسته هاشو که نشون نمیده!

hp1361
جمعه 16 آذر 1386, 17:39 عصر
ببینید وقتی میزنم Regsvr32 mydll.dll یه دیالوگ با این مضمون ظاهر میشه:


LoadLibrary("mydll.dll") failed. The specified module could not be found.


سلام

دوست عزیز این پیغام زمانی ظاهر میشه که DLL مورد نظر در پوشه System32 قرار نداشته باشه (چون تو توی دستوری که تایپ کردی بصورت پیش فرض به اون پوشه ارجاعش میدی ). DLL رو توی اون پوشه کپی کن و دوباره دستور REGSVR32 رو اجرا کن مشکلت حل میشه .

یه راهنمایی کامل در مورد رجیستر کردن DLL تو سیستم خودت و سیستم کاربر

http://www.forum.p30world.com/showthread.php?t=51884&highlight=shamsi.dll



موفق و موید باشی