Old 21st November 2014, 03:31   #1
will49
Junior Member
 
Join Date: Jan 2013
Posts: 6
Question Calling an ANSI string DLL from Unicode NSIS

I have a legacy custom DLL that I need to call from my installer that uses ANSI character strings for parameters. Now I want to move to using the Unicode version of NSIS v3, but I can't easily recompile the DLL to support wide characters.

I've been searching for a way to pass single byte strings to and from the DLL and then convert to Unicode for use within NSIS, but I haven't found a clear answer.

Is "CallAnsiPlugin" any use for what I need? The sample code is pretty unclear to me.

Any pointers are much appreciated.
will49 is offline   Reply With Quote
Old 21st November 2014, 03:36   #2
Afrow UK
Moderator
 
Afrow UK's Avatar
 
Join Date: Nov 2002
Location: Surrey, England
Posts: 8,434
The CallAnsiPlugin plug-in is what you need to use. What is not clear from the example?

Stu
Afrow UK is offline   Reply With Quote
Old 21st November 2014, 04:01   #3
will49
Junior Member
 
Join Date: Jan 2013
Posts: 6
Maybe it's best to show what I had been using before with my DLL:

code:
StrCpy $0 ${NSIS_MAX_STRLEN} ; assign memory to $0
System::Call '$TEMP\${TMP_SUB_DIR}\MYCUSTOMDLL::GetString(t) i(.r0) .r1'
MessageBox MB_OK|MB_ICONEXCLAMATION $0



How would I accomplish the same thing with CallAnsiPlugin? Maybe something like this?

code:
CallAnsiPlugin::Call "$TEMP\${TMP_SUB_DIR}\MYCUSTOMDLL" GetString 1 $0
will49 is offline   Reply With Quote
Old 21st November 2014, 04:39   #4
will49
Junior Member
 
Join Date: Jan 2013
Posts: 6
I should point out that my dll is not an NSIS plugin DLL. It's just a plain Win32 DLL that copies a string into the parameter.
will49 is offline   Reply With Quote
Old 21st November 2014, 13:31   #5
Anders
Moderator
 
Anders's Avatar
 
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 5,505
CallAnsiPlugin only works for NSIS plugins.

The System plugin will work, you just have to use the correct string type and in your case just change (t) to (m).

m = char*
w = wchar_t*
t = TCHAR* / LPTSTR

IntOp $PostCount $PostCount + 1
Anders is offline   Reply With Quote
Old 21st November 2014, 17:18   #6
will49
Junior Member
 
Join Date: Jan 2013
Posts: 6
Thumbs up

Wow that is perfect! Thanks! I like those simple kinds of fixes
will49 is offline   Reply With Quote
Old 21st February 2022, 11:08   #7
taichismith
Junior Member
 
Join Date: Feb 2022
Posts: 1
ANSI to Unicode

Try ANSI to Unicode Migration Tool solution to import ANSI file to Unicode Cloud environment. With an easy and secure connection to Exchange Online in presence of the Internet, it effortlessly uploads ANSI data to Unicode Platform. Supports all versions of Windows OS and Outlook data files. Embedded with high-tech features to provide accurate ANSI to Unicode.

Visit at : https://www.osttopstapp.com/ansi-to-unicode-pst.html
taichismith is offline   Reply With Quote
Reply
Go Back   Winamp & Shoutcast Forums > Developer Center > NSIS Discussion

Tags
unicode dll ansi string

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump