Форум программистов
 

Восстановите пароль или Зарегистрируйтесь на форуме, о проблемах и с заказом рекламы пишите сюда - alarforum@yandex.ru, проверяйте папку спам!

Вернуться   Форум программистов > IT форум > Помощь студентам
Регистрация

Восстановить пароль
Повторная активизация e-mail

Купить рекламу на форуме - 42 тыс руб за месяц

Ответ
 
Опции темы Поиск в этой теме
Старый 14.06.2010, 15:50   #1
дашка-милашка
Новичок
Джуниор
 
Регистрация: 14.06.2010
Сообщений: 1
По умолчанию Динамическое подключение Dll С++

Возникли проблемы в динамическом подключении библиотеки Visual studio 2005.

Объявление в *.h

Код:
#pragma comment(lib, "advapi32")
typedef BOOL (WINAPI *tConvertSidToStringSid)(PSID,LPTSTR *);
tConvertSidToStringSid pConvertSidToStringSid = 0;

typedef BOOL (__cdecl *tConvertSecurityDescriptorToStringSecurityDescriptor)(PSECURITY_DESCRIPTOR, DWORD, SECURITY_INFORMATION, LPTSTR *, PULONG *);
tConvertSecurityDescriptorToStringSecurityDescriptor pConvertSecurityDescriptorToStringSecurityDescriptor = 0;
*.cpp

Код:
int main( int argc, char *argv[] )
{
	PSECURITY_DESCRIPTOR pSecurityDescriptor = NULL;
	DWORD pRequestedStringSDRevision = NULL;
	SECURITY_INFORMATION pSecurityInformation = NULL;
	LPTSTR pStringSecurityDescriptor = NULL;
	PULONG pStringSecurityDescriptorLen= NULL;
	PSID userSID = {0};
	LPTSTR chSID = NULL;

	 //Loading ConvertSidToStringSid
	HINSTANCE handle1 = ::LoadLibrary((LPCSTR)("Advapi32.dll"));
	if (handle1 == NULL)
	{
		cout << "Не удалось подгрузить handl1" << endl;
		return -1;
	}

	pConvertSidToStringSid = (tConvertSidToStringSid) ::GetProcAddress(handle1, "ConvertSidToStringSid");
	if (pConvertSidToStringSid)
	{
		pConvertSidToStringSid(&userSID, &chSID);
	}
	
	HINSTANCE handle2 = ::LoadLibrary((LPCSTR)("Advapi32.dll"));
	if (handle2 == NULL)
	{
		cout << "Не удалось подгрузить handl2" << endl;
		return -1;
	}

	// Loading ConvertSecurityDescriptorToStringSecurityDescriptor
	pConvertSecurityDescriptorToStringSecurityDescriptor = (tConvertSecurityDescriptorToStringSecurityDescriptor) ::GetProcAddress(handle2, "ConvertSecurityDescriptorToStringSecurityDescriptor");
	if (pConvertSecurityDescriptorToStringSecurityDescriptor)
	{
		pConvertSecurityDescriptorToStringSecurityDescriptor(pSecurityDescriptor, 
															pRequestedStringSDRevision, 
															pSecurityInformation, 
															&pStringSecurityDescriptor, 
															&pStringSecurityDescriptorLen);
	}

	setlocale(LC_ALL, "Russian");
	::FreeLibrary(handle1);
	::FreeLibrary(handle2);
	return 0;
}
ругается на

Код:
if (pConvertSecurityDescriptorToStringSecurityDescriptor(
						*pSS,
						SDDL_REVISION_1,							//уровень ревизии выходной строки ( 99,9% случаев SDDL_REVISION_1)
						DACL_SECURITY_INFORMATION |					//битовые маски тех параметров дескриптора,
						SACL_SECURITY_INFORMATION |					//которые мы желаем увидеть в строке
						OWNER_SECURITY_INFORMATION |
						GROUP_SECURITY_INFORMATION /*|
						LABEL_SECURITY_INFORMATION*/,
						&StringSid,									//Непосредственно результирующая строка
						&sizeofString) == 0)								//и ее размер
output:

Код:
1>Compiling...
1>SecureDiscr.cpp
1>.\SecureDiscr.cpp(937) : error C2664: 'BOOL (PSECURITY_DESCRIPTOR,DWORD,SECURITY_INFORMATION,LPTSTR *,PULONG *)' : cannot convert parameter 5 from 'ULONG *' to 'PULONG *'
1>        Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
1>.\SecureDiscr.cpp(937) : error C2664: 'BOOL (PSECURITY_DESCRIPTOR,DWORD,SECURITY_INFORMATION,LPTSTR *,PULONG *)' : cannot convert parameter 4 from 'int' to 'LPTSTR *'
1>        Conversion from integral type to pointer type requires reinterpret_cast, C-style cast or function-style cast
1>.\SecureDiscr.cpp(937) : error C2664: 'BOOL (PSECURITY_DESCRIPTOR,DWORD,SECURITY_INFORMATION,LPTSTR *,PULONG *)' : cannot convert parameter 2 from 'LPTSTR *' to 'DWORD'
1>        There is no context in which this conversion is possible
1>Build log was saved at "file://c:\Users\Тутанхамон\Documents\Visual Studio 2005\Projects\SD_convertor_2\SD_convertor_2\Debug\BuildLog.htm"
1>SD_convertor_2 - 3 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

Последний раз редактировалось дашка-милашка; 14.06.2010 в 15:55.
дашка-милашка вне форума Ответить с цитированием
Ответ


Купить рекламу на форуме - 42 тыс руб за месяц

Опции темы Поиск в этой теме
Поиск в этой теме:

Расширенный поиск


Похожие темы
Тема Автор Раздел Ответов Последнее сообщение
Подключение DLL к программе Mixim Общие вопросы C/C++ 3 30.04.2010 15:28
Подключение DLL Ninetta Общие вопросы .NET 3 01.04.2010 01:06
Подключение DLL __Demon__ C++ Builder 2 09.12.2009 00:29
Dll динамическое подключение MAcK Общие вопросы Delphi 1 11.08.2008 16:45
Подключение DLL 5naip Помощь студентам 9 27.10.2007 20:55