Old 18th May 2017, 14:46   #1
Coby
Junior Member
 
Join Date: Feb 2016
Posts: 36
How can I extract the address of a website from a link?

Hello!
Does anyone know how to extract the base address of a website from a link
Example link: https://www.youtube.com/watch?v=1BmcE6OFRyE
Example website: https://www.youtube.com/
Coby is offline   Reply With Quote
Old 18th May 2017, 17:42   #2
Anders
Moderator
 
Anders's Avatar
 
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 4,481
You can manually parse with NSIS string functions or call InternetCrackUrl with the system plug-in.

IntOp $PostCount $PostCount + 1
Anders is offline   Reply With Quote
Old 20th May 2017, 11:09   #3
Coby
Junior Member
 
Join Date: Feb 2016
Posts: 36
On this subject, my knowledge is minimal, so I have not managed to solve this problem.
The code below shows me a negative result.
However, someone can help me with this issue.

PHP Code:
# DETAILS #

Name "CrackUrl"
OutFile "CrackUrl.exe"
InstallDir "$TEMP\CrackUrl"

# COMPRESS #

SetCompressor /SOLID /FINAL lzma

# ELEVATED #

RequestExecutionLevel 'User'

# RUNTIME SWITCHES #

ShowInstDetails hide
ShowInstDetails nevershow
ShowUnInstDetails nevershow
AutoCloseWindow true 

# INCLUDE #

!include "MUI.nsh"
!include "WinCore.nsh"
!include "nsDialogs.nsh"
!include "FileFunc.nsh"
!include "LogicLib.nsh"
!include "WinMessages.nsh"

# STYLE #

BrandingText /TRIMRIGHT " "

# PAGE #

Page custom "PageWelcomeShow" ""
Page 'InstFiles'

# LANGUAGE #

!insertmacro MUI_LANGUAGE "English"

# INIT #

Function ".onInit"

FunctionEnd

# WELCOME #

Function "PageWelcomeShow" 

  
var /GLOBAL Lbl.Add.Url
  
var /GLOBAL PATH_Link
  
var /GLOBAL Btn_Check
  
var /GLOBAL Lbl.ShowLink1
  
var /GLOBAL Lbl.ShowLink2
  
var /GLOBAL Lbl.ShowLink3

  GetDlgItem 
$0 $HWNDPARENT 1
  EnableWindow 
$0 1

  nsDialogs
::Create /NOUNLOAD 1044
  Pop 
$0
  
${If} $== error
    Abort
  
${EndIf}

  
# Add Url # 

  
nsDialogs::CreateControl /NOUNLOAD STATIC 0x40000000|0x10000000|0x04000000|0x00000100 0x00000020 55904"Add your url:"  
  
Pop $Lbl.Add.Url 

  nsDialogs
::CreateControl /NOUNLOAD EDIT 0x40000000|0x10000000|0x04000000|0x00010000|0x00000080 0 515725"" 
  
Pop $PATH_Link

  nsDialogs
::CreateControl /NOUNLOAD BUTTON 0x40000000|0x10000000|0x04000000|0x00010000 0 8015155"Check"
  
Pop $Btn_Check
  StrCpy 
$1 $Btn_Check
  GetFunctionAddress 
$".onClick.CrackUrl"
  
nsDialogs::onClick /NOUNLOAD $$3

  nsDialogs
::CreateControl /NOUNLOAD STATIC 0x40000000|0x10000000|0x04000000|0x00000100 0x00000020 540855""
  
Pop $Lbl.ShowLink1

  nsDialogs
::CreateControl /NOUNLOAD STATIC 0x40000000|0x10000000|0x04000000|0x00000100 0x00000020 545855""
  
Pop $Lbl.ShowLink2

  nsDialogs
::CreateControl /NOUNLOAD STATIC 0x40000000|0x10000000|0x04000000|0x00000100 0x00000020 550855""
  
Pop $Lbl.ShowLink3

  nsDialogs
::Show

FunctionEnd

!define INTERNET_MAX_HOST_NAME_LENGTH 256
!define INTERNET_MAX_USER_NAME_LENGTH 128
!define INTERNET_MAX_PASSWORD_LENGTH 128
!define INTERNET_MAX_PORT_NUMBER_LENGTH 5
!define INTERNET_MAX_PORT_NUMBER_VALUE 65535
!define INTERNET_MAX_PATH_LENGTH 2048
!define INTERNET_MAX_SCHEME_LENGTH 32
!define INTERNET_MAX_URL_LENGTH ${INTERNET_MAX_SCHEME_LENGTH} + ${INTERNET_MAX_PATH_LENGTH}

Function 
".onClick.CrackUrl"
  
var /GLOBAL LINK
  
${NSD_GetText$PATH_LINK $0
  StrCpy $LINK 
"$0"

  
System::Call "Wininet.dll::InternetCrackUrlA(t '$LINK', i ${INTERNET_MAX_PATH_LENGTH}, i 0) i .r0" 
  
${If} $== "1" 
    
SendMessage $Lbl.ShowLink1 ${WM_SETTEXT"STR:Result: $0"
  
${Else}
    
SendMessage $Lbl.ShowLink1 ${WM_SETTEXT"STR:Result: $0"
  
${Endif}

  
System::Call "Wininet.dll::InternetCrackUrlW(t '$LINK', i ${INTERNET_MAX_PATH_LENGTH}, i 0) i .r0" 
  
${If} $== "1" 
    
SendMessage $Lbl.ShowLink2 ${WM_SETTEXT"STR:Result: $0"
  
${Else}
    
SendMessage $Lbl.ShowLink2 ${WM_SETTEXT"STR:Result: $0"
  
${Endif}

  
System::Call "Winhttp.dll::WinHttpCrackUrl(t '$LINK', i ${INTERNET_MAX_PATH_LENGTH}, i 0) i .r0" 
  
${If} $== "1" 
    
SendMessage $Lbl.ShowLink3 ${WM_SETTEXT"STR:Result: $0"
  
${Else}
    
SendMessage $Lbl.ShowLink3 ${WM_SETTEXT"STR:Result: $0"
  
${Endif}
FunctionEnd

# SECTION #

Section "MAIN" SEC01

SectionEnd

# End #

Function ".onGUIEnd"
FunctionEnd 
Coby is offline   Reply With Quote
Reply
Go Back   Winamp & SHOUTcast Forums > Developer Center > NSIS Discussion

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