According to China Highlights, you need to visit China’s embassy or consulate for a Hong Kong visa.
According to the Embassy of China in Pakistan, you can apply for a visa through them or by sending your documents directly to the Hong Kong Immigration Department in Hong Kong (see the information under the tab marked “Applying,” specifically “Submission of Application”). You could also hire a visa courier service to assist with this. The “Applying” tab also lists the documents you must submit and all the other requirements.
They caution that it can take a month or longer to receive a response.
If you bring your documents to the Chinese Embassy, you’ll pay the Embassy the listed fees. If you apply directly:
the fees in the form of a cashier order or a bank draft should be sent together with the application. The cashier order or bank draft should be issued by a bank which has a connected bank in the HKSAR and made payable to “The Government of the Hong Kong Special Administrative Region”. No cash should be sent with the application.
The above links are for a vist visa. Information for other types of visas may be found on the Immigration Department website.
Credit:stackoverflow.com‘