This website uses cookies. By clicking Accept, you consent to the use of cookies. Click Here to learn more about how we use cookies.
Turn on suggestions
Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.
- Revenera Community
- :
- InstallShield
- :
- InstallShield Forum
- :
- Re: InstallScript generate GUID's?
Subscribe
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Subscribe
- Mute
- Printer Friendly Page
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Jan 18, 2008
07:01 AM
InstallScript generate GUID's?
Is it possible to write an Installscript function to generate a GUID/Uniqueidentifier?
(6) Replies
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Jan 18, 2008
10:11 AM
There's nothing built in, but please search these forums for "generate GUID installscript" to see several code samples...
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Jan 21, 2008
07:34 AM
Maybe I am just blind, but I searched these forums for code/suggestions to do this, and was unable to figure it out. If I used some of the old code, it would not compile in version 14. I also found where in around version 6, someone submitted a help idea to Macrovision, and supposedly they came up with an object "InstallShield.GUID" that would create a guid. Yet I try this and have no luck either.
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Jan 21, 2008
09:50 AM
I haven't tried it, but does the code in [thread=171334]this thread[/thread] work? Or could you post the code that fails?
(There is a GenerateGUID method of the ISWiProject object, but that's available only at design/build time, and not run time.)
(There is a GenerateGUID method of the ISWiProject object, but that's available only at design/build time, and not run time.)
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Jan 21, 2008
10:18 AM
Here are the error messages when it compiles...
C:\HelloWorld\InstallShield\HelloWorldInstall\script files\setup.rul(116) : error C8025: 'S_OK' : undefined identifier
C:\HelloWorld\InstallShield\HelloWorldInstall\script files\setup.rul(145) : error C8025: 'WideCharToMultiByte' : undefined identifier
C:\HelloWorld\InstallShield\HelloWorldInstall\script files\setup.rul(146) : error C8025: 'CP_ACP' : undefined identifier
C:\HelloWorld\InstallShield\HelloWorldInstall\script files\setup.rul(145) : error C8041: '(' : function type required
C:\HelloWorld\InstallShield\HelloWorldInstall\script files\setup.rul(116) : error C8025: 'S_OK' : undefined identifier
C:\HelloWorld\InstallShield\HelloWorldInstall\script files\setup.rul(145) : error C8025: 'WideCharToMultiByte' : undefined identifier
C:\HelloWorld\InstallShield\HelloWorldInstall\script files\setup.rul(146) : error C8025: 'CP_ACP' : undefined identifier
C:\HelloWorld\InstallShield\HelloWorldInstall\script files\setup.rul(145) : error C8041: '(' : function type required
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Jan 21, 2008
10:46 AM
Needs fine-tuning, error-checking, etc., but perhaps try:
[code]prototype OLE32.CoCreateGuid(POINTER);
prototype OLE32.StringFromGUID2(POINTER, BYREF STRING, LONG);
typedef GUID
begin
LONG Data1;
SHORT Data2;
SHORT Data3;
STRING Data4[8];
end;
GUID guid;
GUID POINTER pGuid;
WSTRING wszGuid[40];
STRING szGuid[40];
INT i;
NUMBER n;
function OnBegin( )
begin
guid.Data1 = 0;
guid.Data2 = 0;
guid.Data3 = 0;
pGuid = &guid;
// UseDLL("OLE32.dll");
CoCreateGuid(pGuid);
n = StringFromGUID2(pGuid, wszGuid, 40);
for i = 0 to (n - 1)
szGuid = wszGuid[i * 2];
endfor;
MessageBox("Try this one: " + szGuid, INFORMATION);
// UnUseDLL("OLE32.dll");
end;[/code]
[code]prototype OLE32.CoCreateGuid(POINTER);
prototype OLE32.StringFromGUID2(POINTER, BYREF STRING, LONG);
typedef GUID
begin
LONG Data1;
SHORT Data2;
SHORT Data3;
STRING Data4[8];
end;
GUID guid;
GUID POINTER pGuid;
WSTRING wszGuid[40];
STRING szGuid[40];
INT i;
NUMBER n;
function OnBegin( )
begin
guid.Data1 = 0;
guid.Data2 = 0;
guid.Data3 = 0;
pGuid = &guid;
// UseDLL("OLE32.dll");
CoCreateGuid(pGuid);
n = StringFromGUID2(pGuid, wszGuid, 40);
for i = 0 to (n - 1)
szGuid = wszGuid[i * 2];
endfor;
MessageBox("Try this one: " + szGuid, INFORMATION);
// UnUseDLL("OLE32.dll");
end;[/code]
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Jan 21, 2008
11:10 AM
That worked just fine. I changed the function name and parameters based on what I was doing, so I am reposting the code here in case there are others trying to do the same thing. The ultimate goal was to set the 'MachineID' property to a guid.
Thanks!
export prototype SetMachineID(HWND);
export prototype CreateStringGUID(HWND);
prototype OLE32.CoCreateGuid(POINTER);
prototype OLE32.StringFromGUID2(POINTER, BYREF STRING, LONG);
typedef GUID
begin
LONG Data1;
SHORT Data2;
SHORT Data3;
STRING Data4[8];
end;
GUID guid;
GUID POINTER pGuid;
WSTRING wszGuid[40];
STRING szGuid[40];
INT i;
NUMBER n;
function SetMachineID(hWnd)
begin
guid.Data1 = 0;
guid.Data2 = 0;
guid.Data3 = 0;
pGuid = &guid;
UseDLL("OLE32.dll");
CoCreateGuid(pGuid);
n = StringFromGUID2(pGuid, wszGuid, 40);
for i = 0 to (n - 1)
szGuid = wszGuid[i * 2];
endfor;
MsiSetProperty(hWnd,"MACHINEID",szGuid);
//MessageBox("Try this one: " + szGuid, INFORMATION);
UnUseDLL("OLE32.dll");
end;
Thanks!
export prototype SetMachineID(HWND);
export prototype CreateStringGUID(HWND);
prototype OLE32.CoCreateGuid(POINTER);
prototype OLE32.StringFromGUID2(POINTER, BYREF STRING, LONG);
typedef GUID
begin
LONG Data1;
SHORT Data2;
SHORT Data3;
STRING Data4[8];
end;
GUID guid;
GUID POINTER pGuid;
WSTRING wszGuid[40];
STRING szGuid[40];
INT i;
NUMBER n;
function SetMachineID(hWnd)
begin
guid.Data1 = 0;
guid.Data2 = 0;
guid.Data3 = 0;
pGuid = &guid;
UseDLL("OLE32.dll");
CoCreateGuid(pGuid);
n = StringFromGUID2(pGuid, wszGuid, 40);
for i = 0 to (n - 1)
szGuid = wszGuid[i * 2];
endfor;
MsiSetProperty(hWnd,"MACHINEID",szGuid);
//MessageBox("Try this one: " + szGuid, INFORMATION);
UnUseDLL("OLE32.dll");
end;
![](/skins/images/B841502EC6C60E3ACD181F0696AD21B9/responsive_peak/images/icon_anonymous_message.png)