Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"Image properties" menu item incorrectly handles Unicode characters #31

Closed
Maia-Everett opened this issue Jul 29, 2015 · 4 comments
Closed

Comments

@Maia-Everett
Copy link

To reproduce this issue:

  1. Rename an image file to a name containing non-ASCII characters (e.g. абвгд.png, with Cyrillic letters).
  2. Open the image in ImageGlass.
  3. Right click and select "Image properties".

Instead of the image properties, an error message box pops up, saying that the file "?????.png" cannot be opened. I assume that the file name string is incorrectly converted to/from Unicode.

@d2phap
Copy link
Owner

d2phap commented Jul 30, 2015

Thanks!
I tried these steps. Perhaps, Windows API doesn't support Cyrillic??
Let me research more

@d2phap d2phap added this to the v2.0.1.5 milestone Jul 30, 2015
@Maia-Everett
Copy link
Author

It does. I think the answer may be that you're calling the ANSI version of ShellExecuteEx instead of the Unicode version. Try adding CharSet = CharSet.Unicode to the DllImport attribute.

I'll test the fix locally.

@fire-eggs
Copy link
Collaborator

I have images with Japanese characters in the filename. To get properties to work for these images, I found that two changes were required to ImageInfo.cs:

  1. Declare the DllImport statement with CharSet.Auto:
[DllImport("shell32.dll", CharSet=CharSet.Auto)]
private static extern int ShellExecuteEx(ref SHELLEXECUTEINFO s);
  1. The first four strings in the SHELLEXECUTEINFO structure need to be marshaled appropriately:
            [MarshalAs(UnmanagedType.LPWStr)]
            public string lpVerb;
            [MarshalAs(UnmanagedType.LPWStr)]
            public string lpFile;
            [MarshalAs(UnmanagedType.LPWStr)]
            public string lpParameters;
            [MarshalAs(UnmanagedType.LPWStr)]
            public string lpDirectory;

I tried just setting the lpFile member to LPWStr, but that seemed to be insufficient.

@d2phap
Copy link
Owner

d2phap commented Nov 3, 2015

I also tried declaring the DllImport statement with CharSet.Unicode, but it did not work

d2phap pushed a commit that referenced this issue Jan 1, 2016
@d2phap d2phap closed this as completed Jan 1, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants