سؤال

I'm trying to use the code at http://www.pinvoke.net/default.aspx/coredll/playsound.html

It causes several err msgs, though, namely: "Unexpected character '×'" 26 times.

So, I tried changing the vals to verbatim strings, like so:

SND_SYNC = @"0×0000",

...but now I get "Cannot implicitly convert type 'string' to 'int'

I realize that I can convert those strings to ints, but is that really the way to do it? I'm afraid I might be able to get it to compile that way, but that it still won't work (or worse). What is the appropriate way to mark these hex vals as such, so that the compiler accepts them?

Here's the first bit of the code:

[DllImport("winmm.dll", SetLastError = true)] static extern bool PlaySound(string pszSound, UIntPtr hmod, uint fdwSound);

[Flags]
public enum SoundFlags
{
    SND_SYNC = 0×0000, // <- "unexpected char 'x'"
هل كانت مفيدة؟

المحلول 4

In my case, at least, I had to change all of the lowercase x's to uppercase X's to get it to work.

نصائح أخرى

Just assign them - SND_SYNC = 0x000

I think you want

int val = 0x12fe;

I had the same problem with some code I copied from a website, into a c# Visual Studio 2012 editor, and the x's it pasted were not x's at all but some other character. Replacing them with an actual x character, uppercase or lowercase worked for me.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top