EOLESysError calling CreateOLEObject

classic Classic list List threaded Threaded
14 messages Options
Reply | Threaded
Open this post in threaded view
|

EOLESysError calling CreateOLEObject

Felipe Monteiro de Carvalho
Hello,

I created a very simple program to create a shortcut in the desktop,
but it crashes with EOLESysError (nothing else in the error message).
I tryed to google, but it didn't show much. Am I missing some kind of
initialization call that should be made? thanks, here is the full
program.


{ Creates a link to the Windows calculator in the desktop }
program createshortcut;

{$ifdef fpc}{$mode delphi}{$endif}

uses SysUtils, Windows, ShlObj, ActiveX, ComObj;

var
   IObject: IUnknown;
   ISLink: IShellLink;
   IPFile: IPersistFile;
   PIDL: PItemIDList;
   InFolder: array[0..MAX_PATH] of Char;
   TargetName: String;
   LinkName: WideString;
begin
   TargetName := 'c:\windows\calc.exe';

   { Creates an instance of IShellLink }
   IObject := CreateComObject(CLSID_ShellLink); // Crash here
   ISLink := IObject as IShellLink;
   IPFile := IObject as IPersistFile;

   ISLink.SetPath(pChar(TargetName)) ;
   ISLink.SetWorkingDirectory(pChar(ExtractFilePath(TargetName))) ;

   { Get the desktop location }
   SHGetSpecialFolderLocation(0, CSIDL_DESKTOPDIRECTORY, PIDL) ;
   SHGetPathFromIDList(PIDL, InFolder) ;
   LinkName := InFolder + PathDelim + 'Link created with Free Pascal.lnk';

   { Create the link }
   IPFile.Save(PWChar(LinkName), false);
end.
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: EOLESysError calling CreateOLEObject

Marco van de Voort
> I created a very simple program to create a shortcut in the desktop,
> but it crashes with EOLESysError (nothing else in the error message).
> I tryed to google, but it didn't show much. Am I missing some kind of
> initialization call that should be made? thanks, here is the full
> program.

I'm no com wizard, BUT

Try coinitialize(nil);  (and couninitialize;) from unit activex.

_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: EOLESysError calling CreateOLEObject

Felipe Monteiro de Carvalho
Thanks, but it didn't solve it. The same code (+coinitialize) works in
Delphi 5. Maybe it's the dispinterfaces problem in fpc? Is it expected
to work in 2.2.2 or in 2.3.1?

thanks,
--
Felipe Monteiro de Carvalho
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: EOLESysError calling CreateOLEObject

Marco van de Voort
> Thanks, but it didn't solve it. The same code (+coinitialize) works in
> Delphi 5. Maybe it's the dispinterfaces problem in fpc? Is it expected
> to work in 2.2.2 or in 2.3.1?

I suspect it is in the classid. (the clsid_ constant).

Apparantly when I converted the headers, I thought there only was one ID.
However it seems that classids, and the ids in interfaces are different.

I don't know enough from com to understand the difference, but when I copied and
pasted a value for clsid_ishelllink found on the web, the example worked,
with or without coinit*.\

So the value in the FPC headers is wrong, and the IID values in the headers.
So I grepped the SDK headers, and the shellink clsid is:

DEFINE_SHLGUID(CLSID_ShellLink,         0x00021401L, 0, 0); //
00021401-0000-0000-C000-000000000046

while the iid starts with 000214EE







_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: EOLESysError calling CreateOLEObject

Marco van de Voort
> DEFINE_SHLGUID(CLSID_ShellLink,         0x00021401L, 0, 0); //
> 00021401-0000-0000-C000-000000000046
>
> while the iid starts with 000214EE

Fixed, added some more clsid constants in the process r11434
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: EOLESysError calling CreateOLEObject

Inoussa OUEDRAOGO
In reply to this post by Marco van de Voort
> Apparantly when I converted the headers, I thought there only was one ID.
> However it seems that classids, and the ids in interfaces are different.
>
> I don't know enough from com to understand the difference,

classids are used to identify implementation objects, while iid
identify interfaces as in regular object pascal interface ( used in
QueryInterface ).
The COM obects creation routines ( CoCreateObject and friends ) expect
a classid to locate the implementation object to instanciate.

Hope this help.

Best regards.
--
Inoussa O.
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: EOLESysError calling CreateOLEObject

Marco van de Voort
> > Apparantly when I converted the headers, I thought there only was one ID.
> > However it seems that classids, and the ids in interfaces are different.
> >
> > I don't know enough from com to understand the difference,
>
> classids are used to identify implementation objects, while iid
> identify interfaces as in regular object pascal interface ( used in
> QueryInterface ).
> The COM obects creation routines ( CoCreateObject and friends ) expect
> a classid to locate the implementation object to instanciate.

Ok, makes sense, thanks. Now I understand what I fixed.

However the windows headers don't have a really good place or uniform way to
declare either, so I can't do a bit of grepping and isolate all clsids.

However I found a big batch (160 of them) in the comdef header, with among
them the correct value of clsid_shelllink (so I know they are really
clsids). These are already committed, and I'll try to get it in 2.2.2.

On some website sb hinted that there are even more kinds (fmtids and
cgids), do you happen to know more about those too?
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: EOLESysError calling CreateOLEObject

Inoussa OUEDRAOGO
2008/7/22 Marco van de Voort <[hidden email]>:

>> > Apparantly when I converted the headers, I thought there only was one ID.
>> > However it seems that classids, and the ids in interfaces are different.
>> >
>> > I don't know enough from com to understand the difference,
>>
>> classids are used to identify implementation objects, while iid
>> identify interfaces as in regular object pascal interface ( used in
>> QueryInterface ).
>> The COM obects creation routines ( CoCreateObject and friends ) expect
>> a classid to locate the implementation object to instanciate.
>
> Ok, makes sense, thanks. Now I understand what I fixed.
>
> However the windows headers don't have a really good place or uniform way to
> declare either, so I can't do a bit of grepping and isolate all clsids.
>
> However I found a big batch (160 of them) in the comdef header, with among
> them the correct value of clsid_shelllink (so I know they are really
> clsids). These are already committed, and I'll try to get it in 2.2.2.
>
> On some website sb hinted that there are even more kinds (fmtids and
> cgids), do you happen to know more about those too?

I never heard about fmtids and cgids.


--
Inoussa O.
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: EOLESysError calling CreateOLEObject

Felipe Monteiro de Carvalho
In reply to this post by Marco van de Voort
On Tue, Jul 22, 2008 at 10:59 AM, Marco van de Voort <[hidden email]> wrote:
> Fixed, added some more clsid constants in the process r11434

Could the fix be merged to 2.2.2?

I would like to use the example in the Lazarus book, which will most
likely come after 2.2.2

thanks,
--
Felipe Monteiro de Carvalho
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: EOLESysError calling CreateOLEObject

Felipe Monteiro de Carvalho
Reminder, thanks

On Tue, Jul 22, 2008 at 12:58 PM, Felipe Monteiro de Carvalho
<[hidden email]> wrote:

> On Tue, Jul 22, 2008 at 10:59 AM, Marco van de Voort <[hidden email]> wrote:
>> Fixed, added some more clsid constants in the process r11434
>
> Could the fix be merged to 2.2.2?
>
> I would like to use the example in the Lazarus book, which will most
> likely come after 2.2.2
>
> thanks,
> --
> Felipe Monteiro de Carvalho
>



--
Felipe Monteiro de Carvalho
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: EOLESysError calling CreateOLEObject

Felipe Monteiro de Carvalho
In reply to this post by Felipe Monteiro de Carvalho
Umm ... so can I assume that it wasn't merged?

Maybe it could at least be merged to 2.2.3

thanks,

On Tue, Jul 22, 2008 at 12:58 PM, Felipe Monteiro de Carvalho
<[hidden email]> wrote:

> On Tue, Jul 22, 2008 at 10:59 AM, Marco van de Voort <[hidden email]> wrote:
>> Fixed, added some more clsid constants in the process r11434
>
> Could the fix be merged to 2.2.2?
>
> I would like to use the example in the Lazarus book, which will most
> likely come after 2.2.2
>
> thanks,
> --
> Felipe Monteiro de Carvalho
>



--
Felipe Monteiro de Carvalho
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: EOLESysError calling CreateOLEObject

Vincent Snijders
Felipe Monteiro de Carvalho schreef:
> Umm ... so can I assume that it wasn't merged?
>
> Maybe it could at least be merged to 2.2.3

What revision do you want to be merged. I thought r11434, but that has made it all
the way into fpc 2.2.2, as far as I can see:
http://svn.freepascal.org/cgi-bin/viewvc.cgi/tags/release_2_2_2/packages/winunits-base/src/shlobj.pp?view=log

Vincent
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: EOLESysError calling CreateOLEObject

Felipe Monteiro de Carvalho
Yes, that was it =)

Excellent. I assumed it wasn't merged because no answer was given to my e-mail.

This is pretty good for that part of the book =)

thank you,
--
Felipe Monteiro de Carvalho
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: EOLESysError calling CreateOLEObject

Marco van de Voort
> Yes, that was it =)
>
> Excellent. I assumed it wasn't merged because no answer was given to my e-mail.
>
> This is pretty good for that part of the book =)

Well, that fix, and the win32/win64 can use more than 2GB fix (peflags
directive) should be the only differences between rc2 and the final release.
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal