Two methods for generating the complete path name

Source: Internet
Author: User

1.


Getcurrentdirectory

Get Current Directory

2.


Getmodulefilename

Obtain the complete path
+ Pathremovefilespec

Separate pure path

. 386

. Model
Flat, stdcall

Option Casemap: None

 

Include
Windows. inc

Include
Kernel32.inc

Include
User32.inc

Includelib
Kernel32.lib

Includelib
User32.lib

Include
Shlwapi. inc
; Pathremovefilespec

Use

Includelib
Shlwapi. Lib

 


. Data

Hinstance

Dd
?

Szprofilename
DB
Max_path DUP (?)

Szfilename

DB
'/Test. ini', 0
;

The file name is prefixed.
/

 


. Code

Start:
Invoke
Getmodulehandle, null


MoV
Hinstance, eax


Invoke
Getcurrentdirectory, max_path, ADDR szprofilename
;

Method 1


MoV
EDI, offset szprofilename


Invoke
Lstrlen, EDI


MoV
ECX, offset szfilename
; Ini

File Name


. If
Byte PTR [EDI + eax-1] = '/'
;

The last character of the current path is
/

?



INC
ECX
;

Yes, skip
Ini

File Name
/

To prevent the generation of two
//


. Endif


Invoke
Lstrcat, EDI, ECx
;

Link composition completion path name

;

Note This method


Invoke
MessageBox, null, EDI, null, mb_ OK




Invoke
Getmodulefilename, null, ADDR szprofilename, max_path
;

Method 2



Invoke
Pathremovefilespec, ADDR szprofilename


MoV
EDI, offset szprofilename


Invoke
Lstrlen, EDI


MoV
ECX, offset szfilename


. If
Byte PTR [EDI + eax-1] = '/'



INC
ECX


. Endif


Invoke
Lstrcat, EDI, ECx


Invoke
MessageBox, null, EDI, null, mb_ OK


Invoke
Exitprocess, null


End start

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.