In the clw below, when the parameter IS_StringFromGuid2(ANY,long,long),long,Pascal,Name(‘StringFromGuid2’)
is an ANY, the GUID generated when clicking the template button stays the same on my machine. If I come out of the template back to the appgen tree sometimes it might generate a new guid, but repeated clicks of the template button doesnt change the guid like it should.
If I change the ANY datatype back to a Long datatype, the template button generates guid’s as expected everytime its clicked.
!IS_StringFromGuid2(long,long,long),long,Pascal,Name(‘StringFromGuid2’) !<— This as a long works fine.
The ANY works fine in an exe, but not in a dll used in a template.
Any ideas why?
TIA
1 Global extension template
#TEMPLATE(AAAAIntelligentSiliconLtd,'Template Example Get Guid'),FAMILY('ABC')
#EXTENSION(IS_GetGuid,'IS_GetGuid Global Extension'),Application
#Sheet,HScroll
#Tab('&01 Settings')
#Display('')
#Prompt('',@s40),%LIProcpGUID,Req,At(,,175,10)
#Button('Generate GUID'),At(,,175,12),WhenAccepted(%grpLIGloExtGetGUIDstring(%LIProcpGUID))
#EndButton
#EndTab
#EndSheet
#Group(%grpLIGloExtGetGUIDstring,*%pIO1)
#RunDll('C6GetGuidString.dll','C6GETGUIDSTRING@FRsc',%pIO1),Release,Win32
2 C6GetGuidString.prj file
-- C6GetGuidString
#noedit
#system win32
#model clarion dll
#pragma define(maincode=>off)
#pragma debug(vid=>full)
#compile "C6GetGuidString.clw"
#link "C6GetGuidString.dll"
3 C6GetGuidString.exp file
Library 'C6GetGuidString' GUI
Exports
C6GETGUIDSTRING@FRsc @1
4 C6GetGuidString.clw file
Program
ST:guid Group,Type
Data1 ulong !4
Data2 ushort !2
Data3 ushort !2
Data4 string(8) !8=
End
Map
Module('WinAPI')
IS_CoCreateGuid(long),long,Pascal,Name('CoCreateGuid')
IS_StringFromGuid2(ANY,long,long),long,Pascal,Name('StringFromGuid2') !<--- This as an ANY fixes the GUID when used as a dll. Why?
!IS_StringFromGuid2(long,long,long),long,Pascal,Name('StringFromGuid2') !<--- This as a long works fine.
IS_GetACP(),ulong,Pascal,Name('GetACP')
IS_GetOEMCP(),ulong,Pascal,Name('GetOEMCP')
IS_GetSystemDefaultLCID(),Long,Pascal,Raw,Name('GetSystemDefaultLCID')
IS_GetSystemDefaultLangID(),short,Pascal,Raw,Name('GetSystemDefaultLangID')
IS_WideCharToMultiByte(ulong,ulong,long,long,long,long,long,long),long,Pascal,Raw,Name('WideCharToMultiByte')
IS_lstrlenA(long),long,Pascal,Raw,Name('lstrlenA')
IS_lstrlenW(long),long,Pascal,Raw,Name('lstrlenW')
IS_lstrcpyA(long,long),long,Pascal,Raw,Name('lstrcpyA')
End
C6GetGuidString (*Cstring pGetGuidString)
End
Code
C6GetGuidString Procedure (*Cstring pGetGuidString)
Loc:Guid Like(ST:GUID)
Loc:GuidAddress long
Loc:RPCresult long
Loc:RVlong long
Loc:GuidStringW cstring(90)
Loc:GuidStringWAddress long
Loc:GuidStringWSize long
Loc:GuidStringA cstring(90)
Loc:GuidStringAAddress long
Loc:GuidStringASize long
Loc:CodePage ulong
Loc:dwFlags ulong
Loc:lpWideCharStr long
Loc:cchWideChar long
Loc:lpMultiByteStr long
Loc:cbMultiByte long
Loc:UsedDefaultChar long
Loc:lpUsedDefaultChar long
Loc:ResultLength long
Loc:lpDefaultChar long
IS_WC_COMPOSITECHECK Equate(200h) !// WC_COMPOSITECHECK, WC_DISCARDNS and WC_SEPCHARS are deprecated, not recommended,
!// and provide out-of-date behavior.
!// Windows typically uses Unicode Normalization Form C type sequences,
!// If explicit normalization forms are required, please use NormalizeString.
IS_WC_DEFAULTCHAR Equate(40h)
IS_WC_DISCARDNS Equate(10h)
IS_WC_SEPCHARS Equate(20h)
IS_WC_ERR_INVALID_CHARS Equate(80h)
IS_WC_NO_BEST_FIT_CHARS Equate(400h)
Code
Loc:GuidAddress = Address(Loc:Guid)
Loc:RPCresult = IS_CoCreateGuid(Loc:GuidAddress)
IF Loc:RPCresult = 0 !S_OK !0
Loc:GuidStringWSize = 90
Loc:GuidStringWAddress = Address(Loc:GuidStringW)
Loc:RVlong = IS_StringFromGuid2(Loc:GuidAddress,Loc:GuidStringWAddress,Loc:GuidStringWSize)
IF Loc:RVlong
Loc:CodePage = IS_GetACP()
Loc:dwFlags = 0
!Loc:dwFlags += IS_WC_COMPOSITECHECK !Convert composite checks
!Loc:dwFlags += IS_WC_DEFAULTCHAR !Replace exceptions with the default character during conversion.
!Loc:dwFlags += IS_WC_DISCARDNS !Discard nonspacing characters
!Loc:dwFlags += IS_WC_SEPCHARS !Seperate characters during conversion
!Loc:dwFlags += IS_WC_ERR_INVALID_CHARS !Vista or later. Fail if an invalid input character
!Loc:dwFlags += IS_WC_NO_BEST_FIT_CHARS !Translate unicode characters that do not translate to multibyte equivalents
Loc:lpWideCharStr = Loc:GuidStringWAddress
Loc:cchWideChar = IS_lstrlenW(Loc:GuidStringWAddress) !Returns length of the W (unicode) string. Its a clarion cstring
Loc:GuidStringAAddress = Address(Loc:GuidStringA)
Loc:lpMultiByteStr = Loc:GuidStringAAddress
Loc:cbMultiByte = 90 !IS_lstrlenA(Loc:GuidStringAAddress) !Returns length of the A (ansi) string. Its a clarion cstring.
Loc:lpDefaultChar = 0 !Set to NULL to use system defaults
Loc:UsedDefaultChar = 0
Loc:lpUsedDefaultChar = Address(Loc:UsedDefaultChar)
Loc:ResultLength = IS_WideCharToMultiByte(Loc:CodePage,Loc:dwFlags,Loc:lpWideCharStr,Loc:cchWideChar,Loc:lpMultiByteStr,Loc:cbMultiByte,Loc:lpDefaultChar,Loc:lpUsedDefaultChar)
IF Loc:ResultLength = 0
pGetGuidString = 'Error: Unicode Guid String to Ansi string conversion failed.'
Else
pGetGuidString = Sub(Loc:GuidStringA,1,Loc:ResultLength)
End
Else
pGetGuidString = 'Error: Guid output to string failed'
End
Else
pGetGuidString = 'Error: Guid generation failed'
End