Windows – How to call instance by COM

%fcomskypewindows-xp

I try to call skype instance by COM on F#.
A aim is get mood message.

test.fs

// Import skype4com Api
open SKYPE4COMLib

type SKYPE4COM =
    new() = new SKYPE4COM()

let GetMood =
    let aSkype = new SKYPE4COM
    mood <- aSkype.CurrentUserProfile.MoodText
    mood

But when build(before too),error occur.

Incomplete structured construct at or before this point in expression

Thanks in advance.

this is next version what I think.

test01.fs

// Import skype4com Api
open SKYPE4COMLib

let GetMood =
    let aSkype = new SKYPE4COMLib()              // line 1
    mood <- aSkype.CurrentUserProfile.MoodText   // line 2
    mood                                         // line 3

error message(when building).
line in 1:error FS0039: The type 'SKYPE4COMLib' is not defined
line in 2:error FS0039: The value or constructor 'mood' is not defined
line in 3:error FS0039: The value or constructor 'mood' is not defined

also like that…

Best Answer

Your code has several issues. First of all, your constructor for the SKYPE4COM class appears to be recursive (?!), which is going to cause a stack overflow if you try to create an instance. Secondly, the error that you're receiving is because you are using the new operator, but you haven't completed the call to the constructor (i.e. you need to apply the constructor using parentheses: let aSkype = new SKYPE4COM()). Even then, though, you've got another issue because your type doesn't expose a CurrentUserProfile property, so your code still won't work.

Try something like this:

open SKYPE4COMLib

let getMood() =
  SkypeClass().CurrentUserProfile.MoodText
Related Topic