Dll get version...

Help me get this Crap working :)
just the Normal info or if u want.. also Win2k part..
Const
 DLLVER_PLATFORM_WINDOWS = $00000001;  // Windows 95
 DLLVER_PLATFORM_NT      = $00000002;  // Windows NT

Type
  pDllVersionInfo = ^TDllVersionInfo;
  TDllVersionInfo = Record
    cbSize,
    dwMajorVersion,
    dwMinorVersion,
    dwBuildNumber,
    dwPlatformID : DWord;
   end;

{ // ONLY FOR WINDOWS 2000 DLLS
 TDLLVERSIONINFO2 = Record
  info1      : TDLLVERSIONINFO;
  dwFlags    : DWORD;
  ullVersion : ULONGLONG;
 End;
}


Function DLLGetVersion(dllName : PChar) : pDllVersionInfo;
Var
 hinstDll : Longint;
 ProcDLLGetVersion : Function(pdvi : pDLLVERSIONINFO) : HResult;
 dvi  : pDllVersionInfo;
Begin
 New(dvi);

 dvi^.cbSize := SizeOf(TDLLVersionInfo);
 FillChar(dvi,SizeOf(TDLLVersionInfo),0);

 hinstDll := LoadLibrary(DllName);

 if (hinstDll >0) then
  Begin
   ProcDLLGetVersion := GetProcAddress(hinstDll, 'DllGetVersion');

    if Assigned(ProcDLLGetVersion) then
      Begin
        ProcDLLGetVersion(dvi);
      End;

    ProcDLLGetVersion := nil;
  End;

 FreeLibrary(hinstDll);

 Result := dvi;
 Dispose(dvi);
End;

LVL 2
brainwareAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

LischkeCommented:
Hi brainware, change the declaration of ProcDLLGetVersion to:

ProcDLLGetVersion : Function(pdvi : pDLLVERSIONINFO): HResult; stdcall;

Your forgot the calling convention.

Ciao, Mike
0
brainwareAuthor Commented:
Still crashes on me :(
0
MadshiCommented:
Try this one:

type
  TDllVersion = record
    size         : cardinal;
    majorVersion : cardinal;
    minorVersion : cardinal;
    buildNumber  : cardinal;
    platformID   : cardinal;
  end;

function GetModuleVersion(moduleFile: string) : TDllVersion;
var func : function (var dllVersion: TDllVersion) : integer; stdcall;
    c1   : cardinal;
begin
  ZeroMemory(@result, sizeOf(TDllVersion));
  result.size := sizeOf(TDllVersion);
  c1 := LoadLibrary(pchar(moduleFile));
  if c1 <> 0 then
    try
      func := GetProcAddress(c1, 'DllGetVersion');
      if @func <> nil then func(result);
    finally FreeLibrary(c1) end;
end;

Regards, Madshi.
0
Cloud Class® Course: MCSA MCSE Windows Server 2012

This course teaches how to install and configure Windows Server 2012 R2.  It is the first step on your path to becoming a Microsoft Certified Solutions Expert (MCSE).

simonetCommented:
MAN,

YOU HAVE A VERY DIRTY MOUTH AND OFFENSIVE VOCABULARY.

In your question about CPU features, you made references to the "damn sources" of my component.

About the word "crap", I've lost count of times I've seen it in your last postings.

Although I could give you a solution for this question, I won't, for I feel offended by your vocabulary. And, if you want the sources for my components, feel free to BUY it from me. I am not willing to give away the sources for one who swears all the time and who refers to the code as a "damn" thing.




0
brainwareAuthor Commented:
Simonet: mabye becuse so MANY keeps on posting comments/answers not Valid to what i asked for.  
So far i think a few who have never been posting such was Madshi, Lischke, Williams etc.

And if i did use some "not exactly nice words" im sorry. Im not going to explain my actions, But you can just be happy u aint in the same situation as me.

Regards
Michael.
0
brainwareAuthor Commented:
Thanks Madshi, Works..
submit answer...
0
MadshiCommented:
Thanx...  :-)

BTW, you could have accept my comment as an answer, too...   (-:

Regards, Madshi.
0
MadshiCommented:
Ahhh - now here is the answer...   :-)
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
LischkeCommented:
..and basically I should propose the answer as I have first mentioned the correct solution.

Thank you :-/

Ciao, Mike
0
MadshiCommented:
Well, Mike, your correction was one of at least 2 corrections!! I've rewritten the whole stuff and tested it. As Michael said, with only your 1 correction it did not work.

Regards, Madshi.
0
LischkeCommented:
Yes, I see, the returned pointer which is freed and the var parameter...

Ciao, Mike
0
MadshiCommented:
Yes, and the order of these two lines:

 dvi^.cbSize := SizeOf(TDLLVersionInfo);
 FillChar(dvi,SizeOf(TDLLVersionInfo),0);

:-)

Regards, Madshi.
0
brainwareAuthor Commented:
Well many thanks..

BTW, you could have accept my comment as an answer, too..
Huh???

Anyways.. just wondering.. do u know how to get Version info from DirectX Dlls too? they dont use GetDllVersion :(
0
MadshiCommented:
Look at GetFileVersionInfo.

Michael, if you have asked a question and no answer is waiting (or accepted), you will find the possibility to accept any comment as the answer (in the right top of the comment). So you don't need to ask the experts to post an answer anymore...   :-)

Regards, Madshi.
0
brainwareAuthor Commented:
oh oki.. didnt notice that..
mabye bacuse i dislike the new look so much ehhe..
again thank.. PS: i send a Email to ya..
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Delphi

From novice to tech pro — start learning today.